Exemplo n.º 1
0
def alarm():
    """calls alarm for the end of a cycle"""

    resourcePath = path.join(path.split(__file__)[0], 'resources')
    alarmPath = path.join(path.join(resourcePath, 'audio'), 'alarm.wav')
    wav_obj = WaveObject.from_wave_file(alarmPath)
    wav_obj.play()
Exemplo n.º 2
0
    def __init__(self, sound_file: str):
        """
        Creates all needed instances.

        :param sound_file: absolute path for the alarm sound file
        """
        self.alarm_sound = WaveObject.from_wave_file(sound_file)
        self.alarm_playing = None
Exemplo n.º 3
0
def main_button_callback():
    global tracking
    if not tracking:
        # delete_reset_button()
        main_button.config(text="Stop")
        main_button.config(background="#A02020", activebackground="#A02020")
        if reset_button_f is not None:
            destroy_reset_button()
        graph.play()
        WaveObject.from_wave_file("start_tracking.wav").play()
    else:
        main_button.config(text="Start Tracking")
        main_button.config(background="#3030D0", activebackground="#3030D0")
        graph.pause()
        create_reset_button()
        WaveObject.from_wave_file("stop_tracking.wav").play()

    tracking = not tracking
    update_stats()
Exemplo n.º 4
0
    def _load_sounds(self):
        if not WaveObject:
            raise ResourceLoadingError(False)

        for file_name in listdir(self._sound_path):
            if not file_name.endswith('.wav'):
                continue
            file_name = paths.join(self._sound_path, file_name)
            name = paths.splitext(paths.basename(file_name))[0]
            try:
                self._sounds[name] = WaveObject.from_wave_file(file_name)
            except OSError as exc:
                raise ResourceLoadingError(False, *exc.args)
Exemplo n.º 5
0
    def play(self, start, end, loop=False):
        from simpleaudio import WaveObject

        dat = b''.join(self.frames[start:end])
        ndat = np.frombuffer(dat, '<i2').reshape((-1, 2))

        self.wave_intro = WaveObject.from_wave_file(
            self._to_memory_file(0, end)
        )
        self.wave_loop = WaveObject.from_wave_file(
            self._to_memory_file(start, end)
        )

        try:
            play_obj = self.wave_intro.play()
            play_obj.wait_done()

            while loop:
                play_obj = self.wave_loop.play()
                play_obj.wait_done()

        except KeyboardInterrupt:
            print()
Exemplo n.º 6
0
def mehrp_until_input(prompt=None):
    mehrp_wave = WaveObject.from_wave_file(MEHRP_PATH)

    play_thread = LoopRunnableThread(target=_play_wave, args=(mehrp_wave, ))
    play_thread.start()

    if prompt:
        value = input(prompt)
    else:
        value = input()

    play_thread.stop()
    play_thread.join()

    return value
Exemplo n.º 7
0
class WhackMole(LaunchKey):
    state = [False for n in range(0, 26)]
    decay_state = [0 for n in range(0, 26)]

    score = 0
    colors = [TEAL, PINK]
    squeak_sound = WaveObject.from_wave_file("squeak.wav")
    oof_sound = WaveObject.from_wave_file("oof.wav")

    def __init__(self):
        self.setup()
        self.clear_lights()

        print("Go!")
        self.game_loop()

    def process_decay(self, n):
        if self.decay_state[n] == 1:
            self.decay_state[n] = 0
            self.state[n] = False
            self.light(n, BRIGHT_WHITE)

            print("Whoops! You missed the mole at {}".format(n))
            self.fail()

        elif self.decay_state[n] > 1:
            self.decay_state[n] = self.decay_state[n] - 1

    def add_mole(self, n):
        self.process_decay(n)

        if randint(1, 1500) < 10:
            color = choice(self.colors)
            self.state[n] = True
            self.light(n, color)

            self.decay_state[n] = randint(20, 40)

    def add_moles(self):
        for n in range(1, 9):
            self.add_mole(n)

        for n in range(17, 25):
            self.add_mole(n)

    def whack(self, position):
        if self.state[position]:
            self.score = self.score + 1
            self.state[position] = False
            self.decay_state[position] = 0

            self.light(position, BRIGHT_WHITE)

            self.squeak_sound.play()

            print("Whacked Mole at {}! Score = {}".format(position, self.score))
        else:
            print("Oops! You did not hit the mole at {}".format(position))
            self.fail()

    def fail(self):
        self.oof_sound.play()
        self.score = self.score - 1

    def game_loop(self):
        while True:
            for msg in self.ctrl_in.iter_pending():
                if msg.type == "note_on":
                    if msg.note < 95:
                        continue

                    self.whack(msg.note - 95)

            self.add_moles()

            sleep(0.05)
Exemplo n.º 8
0
 def play_sound(self, name):
     wave_obj = WaveObject.from_wave_file(self._prefix_path + name +
                                          self._suffix_path)
     play_obj = wave_obj.play()
     play_obj.wait_done()
Exemplo n.º 9
0
import time
import wave
import numpy as np

from keras.models import load_model
from simpleaudio import WaveObject as wo

face = cv2.CascadeClassifier(
    r'haar cascade files\haarcascade_frontalface_alt.xml')
leye = cv2.CascadeClassifier(
    r'haar cascade files\haarcascade_lefteye_2splits.xml')
reye = cv2.CascadeClassifier(
    r'haar cascade files\haarcascade_righteye_2splits.xml')
model = load_model('models/cnncat2.h5')

sound = wo.from_wave_file('alarm.wav')
sound_obj = None

path = os.getcwd()
color_line_BGR = (0, 0, 0)  # Lavender = (234, 206, 199)

cap = cv2.VideoCapture(0)
font = cv2.FONT_HERSHEY_COMPLEX_SMALL
score = 0
thicc = 2
rpred, lpred = [], []


def draw_box(frame, height, end=None, color=(0, 0, 0), thickness=cv2.FILLED):
    '''
    Draw a black (default) box at the bottom left of the frame
Exemplo n.º 10
0
def load_sound(folder_path: Path, snd: str) -> WaveObject:
    return WaveObject.from_wave_file((folder_path / snd).as_posix())
Exemplo n.º 11
0
import os
import glob
import time
from sys import platform

if platform == "linux" or platform == "linux2" or platform == "darwin":
    try:
        from simpleaudio import WaveObject
    except ImportError:
        exit(1)
    for file in glob.glob('./downloaded/*.wav'):  # play all wav music in file
        wave = WaveObject.from_wave_file(file)
        play = wave.play()
        play.wait_done()
elif platform == "win32" or platform == "cygwin":
    try:
        import winsound
    except ImportError:
        exit(1)
    for file in glob.glob('./downloaded/*.wav'):
        winsound.PlaySound(file, winsound.SND_FILENAME)
Exemplo n.º 12
0
def play_random_sound():
    WaveObject.from_wave_file(join(get_sound_dir(),
                                   choice(get_sound_files()))).play()
Exemplo n.º 13
0
def mehrp(count):
    mehrp_wave = WaveObject.from_wave_file(MEHRP_PATH)

    for _ in range(0, count):
        _play_wave(mehrp_wave)
Exemplo n.º 14
0
def play_critical():
    wave_obj = WaveObject.from_wave_file(CRITICAL_FILE_NAME)
    play_obj = wave_obj.play()
    play_obj.wait_done()
Exemplo n.º 15
0
#!/usr/bin/env python3
import string
import time

from simpleaudio import WaveObject
from pynput import keyboard

sounds = {
    "backspace": WaveObject.from_wave_file("sounds/backspace.wav"),
    "caps_lock": WaveObject.from_wave_file("sounds/caps_lock.wav"),
    "enter": WaveObject.from_wave_file("sounds/enter.wav"),
    "space": WaveObject.from_wave_file("sounds/space.wav")
}
for letter in list(string.ascii_lowercase):
    sounds[letter] = WaveObject.from_wave_file(f"sounds/{letter}.wav")


def on_press(key):
    if isinstance(key, keyboard.KeyCode):  # Alphanumeric keys
        key_str = key.char.lower()
    elif isinstance(key, keyboard.Key):  # Special keys
        key_str = str(key)[4:]
    else:  # Unknown keys are None
        return

    try:
        play_obj = sounds[key_str].play()
    except KeyError:
        pass

Exemplo n.º 16
0
def play_sound(filename):
    WaveObject.from_wave_file(filename).play()
Exemplo n.º 17
0
def reset_button_callback():
    graph.reset()
    WaveObject.from_wave_file("reset.wav").play()
    f'./Bases/{base_name}' for base_name in listdir('./Bases')
    if base_name.endswith('csv')
]
cols = [
    'dataNotificacao', 'dataInicioSintomas', 'sintomas', 'profissionalSaude',
    'condicoes', 'estadoTeste', 'tipoTeste', 'resultadoTeste', 'sexo',
    'estado', 'municipio', 'idade', 'evolucaoCaso', 'classificacaoFinal'
]

for i in range(0, len(bases_names), 2):
    csvs = [
        DictReader(open(bases_names[i]), delimiter=';'),
        DictReader(open(bases_names[i + 1]), delimiter=';')
    ]

    df1 = pd.DataFrame.from_dict(csvs[0])[cols]
    df2 = pd.DataFrame.from_dict(csvs[1])[cols]
    # df = pd.concat([pd.DataFrame.from_dict(csv_file)[cols] for csv_file in csvs])
    df = pd.concat([df1, df2])

    df.to_csv(
        f'./Bases/Concat/{bases_names[i][bases_names[i].find("-") + 1:bases_names[i].rfind(".")]}_{bases_names[i + 1][bases_names[i + 1].find("-") + 1:bases_names[i + 1].rfind(".")]}.csv',
        sep=';')
    print(
        f'Arquivo {bases_names[i][bases_names[i].find("-") + 1:bases_names[i].rfind(".")]}_{bases_names[i + 1][bases_names[i + 1].find("-") + 1:bases_names[i + 1].rfind(".")]}.csv salvo!'
    )

# print(df.info())
from simpleaudio import WaveObject as wo
wo.from_wave_file(f'./blip.mp3').play().wait_done()