Merge branch 'AudioTranscriber' into develop
This commit is contained in:
6
VRCT.py
6
VRCT.py
@@ -467,12 +467,11 @@ class App(CTk):
|
|||||||
self.mic_transcriber = AudioTranscriber(
|
self.mic_transcriber = AudioTranscriber(
|
||||||
speaker=False,
|
speaker=False,
|
||||||
source=self.mic_audio_recorder.source,
|
source=self.mic_audio_recorder.source,
|
||||||
language=transcription_lang[self.INPUT_MIC_VOICE_LANGUAGE],
|
|
||||||
phrase_timeout=self.INPUT_MIC_PHRASE_TIMEOUT,
|
phrase_timeout=self.INPUT_MIC_PHRASE_TIMEOUT,
|
||||||
max_phrases=self.INPUT_MIC_MAX_PHRASES,
|
max_phrases=self.INPUT_MIC_MAX_PHRASES,
|
||||||
)
|
)
|
||||||
def mic_transcript_to_chatbox():
|
def mic_transcript_to_chatbox():
|
||||||
self.mic_transcriber.transcribe_audio_queue(self.mic_audio_queue)
|
self.mic_transcriber.transcribe_audio_queue(self.mic_audio_queue, transcription_lang[self.INPUT_MIC_VOICE_LANGUAGE])
|
||||||
message = self.mic_transcriber.get_transcript()
|
message = self.mic_transcriber.get_transcript()
|
||||||
if len(message) > 0:
|
if len(message) > 0:
|
||||||
# word filter
|
# word filter
|
||||||
@@ -566,13 +565,12 @@ class App(CTk):
|
|||||||
self.spk_transcriber = AudioTranscriber(
|
self.spk_transcriber = AudioTranscriber(
|
||||||
speaker=True,
|
speaker=True,
|
||||||
source=self.spk_audio_recorder.source,
|
source=self.spk_audio_recorder.source,
|
||||||
language=transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE],
|
|
||||||
phrase_timeout=self.INPUT_SPEAKER_PHRASE_TIMEOUT,
|
phrase_timeout=self.INPUT_SPEAKER_PHRASE_TIMEOUT,
|
||||||
max_phrases=self.INPUT_SPEAKER_MAX_PHRASES,
|
max_phrases=self.INPUT_SPEAKER_MAX_PHRASES,
|
||||||
)
|
)
|
||||||
|
|
||||||
def spk_transcript_to_textbox():
|
def spk_transcript_to_textbox():
|
||||||
self.spk_transcriber.transcribe_audio_queue(self.spk_audio_queue)
|
self.spk_transcriber.transcribe_audio_queue(self.spk_audio_queue, transcription_lang[self.INPUT_SPEAKER_VOICE_LANGUAGE])
|
||||||
message = self.spk_transcriber.get_transcript()
|
message = self.spk_transcriber.get_transcript()
|
||||||
if len(message) > 0:
|
if len(message) > 0:
|
||||||
# translate
|
# translate
|
||||||
|
|||||||
@@ -9,9 +9,8 @@ PHRASE_TIMEOUT = 3
|
|||||||
MAX_PHRASES = 10
|
MAX_PHRASES = 10
|
||||||
|
|
||||||
class AudioTranscriber:
|
class AudioTranscriber:
|
||||||
def __init__(self, speaker, source, language, phrase_timeout, max_phrases):
|
def __init__(self, speaker, source, phrase_timeout, max_phrases):
|
||||||
self.speaker = speaker
|
self.speaker = speaker
|
||||||
self.language = language
|
|
||||||
self.phrase_timeout = phrase_timeout
|
self.phrase_timeout = phrase_timeout
|
||||||
self.max_phrases = max_phrases
|
self.max_phrases = max_phrases
|
||||||
self.transcript_data = []
|
self.transcript_data = []
|
||||||
@@ -27,7 +26,7 @@ class AudioTranscriber:
|
|||||||
"process_data_func": self.process_speaker_data if speaker else self.process_speaker_data
|
"process_data_func": self.process_speaker_data if speaker else self.process_speaker_data
|
||||||
}
|
}
|
||||||
|
|
||||||
def transcribe_audio_queue(self, audio_queue):
|
def transcribe_audio_queue(self, audio_queue, language):
|
||||||
# while True:
|
# while True:
|
||||||
audio, time_spoken = audio_queue.get()
|
audio, time_spoken = audio_queue.get()
|
||||||
self.update_last_sample_and_phrase_status(audio, time_spoken)
|
self.update_last_sample_and_phrase_status(audio, time_spoken)
|
||||||
@@ -37,7 +36,7 @@ class AudioTranscriber:
|
|||||||
# fd, path = tempfile.mkstemp(suffix=".wav")
|
# fd, path = tempfile.mkstemp(suffix=".wav")
|
||||||
# os.close(fd)
|
# os.close(fd)
|
||||||
audio_data = self.audio_sources["process_data_func"]()
|
audio_data = self.audio_sources["process_data_func"]()
|
||||||
text = self.audio_recognizer.recognize_google(audio_data, language=self.language)
|
text = self.audio_recognizer.recognize_google(audio_data, language=language)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
Reference in New Issue
Block a user