From 84f4a796e1df7feb6bf2e659bcd93badc2f36f39 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 30 Nov 2020 22:52:36 +0100 Subject: [PATCH] release --- soui.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/soui.py b/soui.py index 874e9aa..9684240 100644 --- a/soui.py +++ b/soui.py @@ -3,20 +3,20 @@ import sounddevice as sd from time import sleep from tkinter import Tk, Canvas, Label, PhotoImage +speaking = False + class Microphone: - def __init__(self): - self.speaking = False - def audio_callback(self, indata, frames, time, status): + global speaking volume_norm = np.linalg.norm(indata) * 10 - if int(volume_norm) > 2: - self.speaking = True - elif int(volume_norm) < 2: - self.speaking = False + if int(volume_norm) > 2 and speaking == False: + speaking = True + elif int(volume_norm) < 2 and speaking == True: + speaking = False def get_status_speaking(self): - return self.speaking + return speaking def start(self): with sd.InputStream(callback = self.audio_callback): @@ -25,7 +25,7 @@ class Microphone: class Affichage: def __init__(self): - self.buffer = 500 # milliseconds + self.buffer = 100 # milliseconds self.speaking = "speaking.png" self.notspeaking = "not_speaking.png" @@ -37,7 +37,6 @@ class Affichage: def get_image(self): if Microphone().get_status_speaking(): - print("parle") self.img = PhotoImage(file = self.speaking) else: self.img = PhotoImage(file = self.notspeaking)