add dictation model
This commit is contained in:
@@ -19,6 +19,26 @@ DIALECT = "excel-tab"
|
||||
# Results Classes
|
||||
|
||||
|
||||
def dictation_process(
|
||||
text_lines: list[str], process_file: ProcessFile
|
||||
) -> list[TranslationResult]:
|
||||
"""Process for Dictation translation"""
|
||||
results = []
|
||||
for n, line in enumerate(text_lines):
|
||||
line = line.strip()
|
||||
audio_path = process_file.resources / f"N{n:03n}.wav"
|
||||
if not audio_path.exists():
|
||||
audio = TTS.MODEL.generate(f"{line}。", language_id=LANGUAGES.CN)
|
||||
torchaudio.save(audio_path, audio, TTS.MODEL.sr)
|
||||
translated = argostranslate.translate.translate(
|
||||
line, LANGUAGES.CN, process_file.language_id
|
||||
)
|
||||
results.append(
|
||||
TranslationResult(process_file.language_id, translated, line, audio_path)
|
||||
)
|
||||
return results
|
||||
|
||||
|
||||
def translator_process(
|
||||
text_lines: list[str], process_file: ProcessFile
|
||||
) -> list[TranslationResult]:
|
||||
|
||||
Reference in New Issue
Block a user