test auding pauses toaudio genberation
This commit is contained in:
@@ -22,6 +22,10 @@ PHRASES_TYPE = ".phrases"
|
|||||||
DICT_TYPE = ".dictionary"
|
DICT_TYPE = ".dictionary"
|
||||||
DICTATION_TYPE = ".dictation"
|
DICTATION_TYPE = ".dictation"
|
||||||
|
|
||||||
|
# time dalays
|
||||||
|
WORD = 0.1
|
||||||
|
COMMA = 0.5
|
||||||
|
POINT = 1.0
|
||||||
|
|
||||||
class LANGUAGES:
|
class LANGUAGES:
|
||||||
"""Available laguages for translation"""
|
"""Available laguages for translation"""
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import argostranslate.translate
|
|||||||
import torchaudio
|
import torchaudio
|
||||||
|
|
||||||
# Local
|
# Local
|
||||||
from .constants import LANGUAGES
|
from .constants import LANGUAGES, WORD, COMMA
|
||||||
from .utility import CCCEDICT, TTS, DictionaryResult, ProcessFile, TranslationResult
|
from .utility import CCCEDICT, TTS, DictionaryResult, ProcessFile, TranslationResult
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
@@ -27,7 +27,8 @@ def dictation_process(
|
|||||||
for n, line in enumerate(text_lines):
|
for n, line in enumerate(text_lines):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
line = " ".join(line.split())
|
line = " ".join(line.split())
|
||||||
line = line.replace(",", ", 。。。 ")
|
audio_line = f"[pause:{WORD}s]".join(line)
|
||||||
|
audio_line = audio_line.replace(",", f",[pause:{COMMA}s]")
|
||||||
audio_path = process_file.resources / f"N{n:03n}.wav"
|
audio_path = process_file.resources / f"N{n:03n}.wav"
|
||||||
if not audio_path.exists():
|
if not audio_path.exists():
|
||||||
audio = TTS.MODEL.generate(
|
audio = TTS.MODEL.generate(
|
||||||
@@ -51,11 +52,12 @@ def translator_process(
|
|||||||
for n, line in enumerate(text_lines):
|
for n, line in enumerate(text_lines):
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
line = " ".join(line.split())
|
line = " ".join(line.split())
|
||||||
line = line.replace(",", ", 。。。 ")
|
audio_line = "[pause:0.1s]".join(line)
|
||||||
|
audio_line = audio_line.replace(",", ",[pause:0.5s]")
|
||||||
audio_path = process_file.resources / f"N{n:03n}.wav"
|
audio_path = process_file.resources / f"N{n:03n}.wav"
|
||||||
if not audio_path.exists():
|
if not audio_path.exists():
|
||||||
audio = TTS.MODEL.generate(
|
audio = TTS.MODEL.generate(
|
||||||
f"{line}。", language_id=LANGUAGES.CN, **TTS.DEFAULTS
|
f"{audio_line}。", language_id=LANGUAGES.CN, **TTS.DEFAULTS
|
||||||
)
|
)
|
||||||
torchaudio.save(audio_path, audio, TTS.MODEL.sr)
|
torchaudio.save(audio_path, audio, TTS.MODEL.sr)
|
||||||
translated = argostranslate.translate.translate(
|
translated = argostranslate.translate.translate(
|
||||||
|
|||||||
Reference in New Issue
Block a user