add dictation model

This commit is contained in:
Wolfang Torres
2026-06-20 14:10:17 +08:00
parent ebf2d58207
commit ebc9aa77a7
4 changed files with 125 additions and 10 deletions

View File

@@ -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]: