update transcription
add daemon=True
This commit is contained in:
18
VRCT.py
18
VRCT.py
@@ -1,9 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import queue
|
import queue
|
||||||
import time
|
|
||||||
import customtkinter
|
import customtkinter
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import pyaudiowpatch as pyaudio
|
||||||
|
|
||||||
import utils
|
import utils
|
||||||
import translation
|
import translation
|
||||||
@@ -305,7 +305,8 @@ class App(customtkinter.CTk):
|
|||||||
## set transcription instance
|
## set transcription instance
|
||||||
self.mic_queue = queue.Queue()
|
self.mic_queue = queue.Queue()
|
||||||
self.spk_queue = queue.Queue()
|
self.spk_queue = queue.Queue()
|
||||||
self.vr = transcription.VoiceRecognizer(self.mic_queue, self.spk_queue)
|
self.p = pyaudio.PyAudio()
|
||||||
|
self.vr = transcription.VoiceRecognizer(self.p, self.mic_queue, self.spk_queue)
|
||||||
self.CHOICE_MIC_DEVICE = self.CHOICE_MIC_DEVICE if self.CHOICE_MIC_DEVICE is not None else self.vr.search_default_device()[0]
|
self.CHOICE_MIC_DEVICE = self.CHOICE_MIC_DEVICE if self.CHOICE_MIC_DEVICE is not None else self.vr.search_default_device()[0]
|
||||||
self.CHOICE_SPEAKER_DEVICE = self.CHOICE_SPEAKER_DEVICE if self.CHOICE_SPEAKER_DEVICE is not None else self.vr.search_default_device()[1]
|
self.CHOICE_SPEAKER_DEVICE = self.CHOICE_SPEAKER_DEVICE if self.CHOICE_SPEAKER_DEVICE is not None else self.vr.search_default_device()[1]
|
||||||
|
|
||||||
@@ -541,20 +542,9 @@ class App(customtkinter.CTk):
|
|||||||
self.attributes("-topmost", True)
|
self.attributes("-topmost", True)
|
||||||
|
|
||||||
def delete_window(self):
|
def delete_window(self):
|
||||||
if isinstance(self.th_vr_listen_mic, utils.thread_fnc):
|
self.quit()
|
||||||
while not self.th_vr_listen_mic.stopped():
|
|
||||||
self.th_vr_listen_mic.stop()
|
|
||||||
if isinstance(self.th_vr_recognize_mic, utils.thread_fnc):
|
|
||||||
while not self.th_vr_recognize_mic.stopped():
|
|
||||||
self.th_vr_recognize_mic.stop()
|
|
||||||
if self.vr.spk_stream is not None:
|
|
||||||
self.vr.close_spk_stream()
|
|
||||||
if isinstance(self.th_vr_recognize_spk, utils.thread_fnc):
|
|
||||||
while not self.th_vr_recognize_spk.stopped():
|
|
||||||
self.th_vr_recognize_spk.stop()
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
app = App()
|
app = App()
|
||||||
|
|||||||
@@ -1,17 +1,12 @@
|
|||||||
import io
|
|
||||||
import queue
|
|
||||||
import numpy as np
|
|
||||||
import soundcard as sc
|
|
||||||
import soundfile as sf
|
|
||||||
import sounddevice as sd
|
import sounddevice as sd
|
||||||
import speech_recognition as sr
|
import speech_recognition as sr
|
||||||
import pyaudiowpatch as pyaudio
|
import pyaudiowpatch as pyaudio
|
||||||
|
|
||||||
# VoiceRecognizer
|
# VoiceRecognizer
|
||||||
class VoiceRecognizer():
|
class VoiceRecognizer():
|
||||||
def __init__(self, mic_queue, spk_queue):
|
def __init__(self, p_audio, mic_queue, spk_queue):
|
||||||
self.r = sr.Recognizer()
|
self.r = sr.Recognizer()
|
||||||
self.p = pyaudio.PyAudio()
|
self.p = p_audio
|
||||||
|
|
||||||
self.languages = [
|
self.languages = [
|
||||||
"ja-JP","en-US","en-GB","af-ZA","ar-DZ","ar-BH","ar-EG","ar-IL","ar-IQ","ar-JO","ar-KW","ar-LB","ar-MA",
|
"ja-JP","en-US","en-GB","af-ZA","ar-DZ","ar-BH","ar-EG","ar-IL","ar-IQ","ar-JO","ar-KW","ar-LB","ar-MA",
|
||||||
@@ -138,6 +133,7 @@ class VoiceRecognizer():
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
import queue
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
mic_queue = queue.Queue()
|
mic_queue = queue.Queue()
|
||||||
|
|||||||
4
utils.py
4
utils.py
@@ -26,8 +26,8 @@ def print_textbox(textbox, message, tags=None):
|
|||||||
textbox.see("end")
|
textbox.see("end")
|
||||||
|
|
||||||
class thread_fnc(threading.Thread):
|
class thread_fnc(threading.Thread):
|
||||||
def __init__(self, fnc, *args, **kwargs):
|
def __init__(self, fnc, daemon=True, *args, **kwargs):
|
||||||
super(thread_fnc, self).__init__(*args, **kwargs)
|
super(thread_fnc, self).__init__(daemon=daemon, *args, **kwargs)
|
||||||
self.fnc = fnc
|
self.fnc = fnc
|
||||||
self._stop = threading.Event()
|
self._stop = threading.Event()
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user