change topurch audio to soundfile
This commit is contained in:
@@ -5,7 +5,7 @@ import csv
|
||||
|
||||
# Pip
|
||||
import argostranslate.translate
|
||||
import torchaudio
|
||||
import soundfile as sf
|
||||
|
||||
# Local
|
||||
from .constants import LANGUAGES
|
||||
@@ -32,7 +32,7 @@ def dictation_process(
|
||||
audio_path = process_file.resources / f"N{n:03n}.wav"
|
||||
if not audio_path.exists():
|
||||
wavs, sr = TTS.generate(f"{audio_line}。")
|
||||
torchaudio.save(audio_path, wavs[0], sr)
|
||||
sf.write(audio_path, wavs[0], sr)
|
||||
translated = argostranslate.translate.translate(
|
||||
line, LANGUAGES.CN, process_file.language_id
|
||||
)
|
||||
@@ -55,7 +55,7 @@ def translator_process(
|
||||
audio_path = process_file.resources / f"N{n:03n}.wav"
|
||||
if not audio_path.exists():
|
||||
wavs, sr = TTS.generate(f"{audio_line}。")
|
||||
torchaudio.save(audio_path, wavs[0], sr)
|
||||
sf.write(audio_path, wavs[0], sr)
|
||||
translated = argostranslate.translate.translate(
|
||||
line, LANGUAGES.CN, process_file.language_id
|
||||
)
|
||||
@@ -118,7 +118,7 @@ def dictionary_process(process_file: ProcessFile) -> list[DictionaryResult]:
|
||||
audio_path = process_file.resources / f"{line['pinyin']}.wav"
|
||||
if not audio_path.exists():
|
||||
wavs, sr = TTS.generate(f"{line['simplified']}。")
|
||||
torchaudio.save(audio_path, wavs[0], sr)
|
||||
sf.write(audio_path, wavs[0], sr)
|
||||
print(line)
|
||||
result = DictionaryResult(
|
||||
**line, audio_path=audio_path, language_id=process_file.language_id
|
||||
|
||||
Reference in New Issue
Block a user