1. support voice preview

2, update version to 1.1.6
This commit is contained in:
harry 2024-05-13 18:29:59 +08:00
parent fb3aadeccc
commit 6de3d6eedc
7 changed files with 46 additions and 5 deletions

View File

@ -56,7 +56,7 @@ listen_port = _cfg.get("listen_port", 8080)
project_name = _cfg.get("project_name", "MoneyPrinterTurbo")
project_description = _cfg.get("project_description",
"<a href='https://github.com/harry0703/MoneyPrinterTurbo'>https://github.com/harry0703/MoneyPrinterTurbo</a>")
project_version = _cfg.get("project_version", "1.1.5")
project_version = _cfg.get("project_version", "1.1.6")
reload_debug = False
imagemagick_path = app.get("imagemagick_path", "")

View File

@ -1035,6 +1035,7 @@ def tts(text: str, voice_name: str, voice_file: str) -> [SubMaker, None]:
def azure_tts_v1(text: str, voice_name: str, voice_file: str) -> [SubMaker, None]:
voice_name = parse_voice_name(voice_name)
text = text.strip()
for i in range(3):
try:

View File

@ -416,6 +416,10 @@ with middle_panel:
index=0)
with st.container(border=True):
st.write(tr("Audio Settings"))
# tts_providers = ['edge', 'azure']
# tts_provider = st.selectbox(tr("TTS Provider"), tts_providers)
voices = voice.get_all_azure_voices(
filter_locals=support_locales)
friendly_names = {
@ -442,6 +446,26 @@ with middle_panel:
params.voice_name = voice_name
config.ui['voice_name'] = voice_name
if st.button(tr("Play Voice")):
play_content = params.video_subject
if not play_content:
play_content = params.video_script
if not play_content:
play_content = tr("Voice Example")
with st.spinner(tr("Synthesizing Voice")):
temp_dir = utils.storage_dir("temp", create=True)
audio_file = os.path.join(temp_dir, f"tmp-voice-{str(uuid4())}.mp3")
sub_maker = voice.tts(text=play_content, voice_name=voice_name, voice_file=audio_file)
# if the voice file generation failed, try again with a default content.
if not sub_maker:
play_content = "This is a example voice. if you hear this, the voice synthesis failed with the original content."
sub_maker = voice.tts(text=play_content, voice_name=voice_name, voice_file=audio_file)
if sub_maker and os.path.exists(audio_file):
st.audio(audio_file, format="audio/mp3")
if os.path.exists(audio_file):
os.remove(audio_file)
if voice.is_azure_v2_voice(voice_name):
saved_azure_speech_region = config.azure.get(f"speech_region", "")
saved_azure_speech_key = config.azure.get(f"speech_key", "")

View File

@ -66,6 +66,10 @@
"TikTok": "TikTok (TikTok support is coming soon)",
"Bilibili": "Bilibili (Bilibili support is coming soon)",
"Xiaohongshu": "Xiaohongshu (Xiaohongshu support is coming soon)",
"Local file": "Local file"
"Local file": "Local file",
"Play Voice": "Play Voice",
"Voice Example": "This is an example text for testing speech synthesis",
"Synthesizing Voice": "Synthesizing voice, please wait...",
"TTS Provider": "Select the voice synthesis provider"
}
}

View File

@ -67,6 +67,10 @@
"TikTok": "TikTok (TikTok support is coming soon)",
"Bilibili": "Bilibili (Bilibili support is coming soon)",
"Xiaohongshu": "Xiaohongshu (Xiaohongshu support is coming soon)",
"Local file": "Local file"
"Local file": "Local file",
"Play Voice": "Play Voice",
"Voice Example": "This is an example text for testing speech synthesis",
"Synthesizing Voice": "Synthesizing voice, please wait...",
"TTS Provider": "Select the voice synthesis provider"
}
}

View File

@ -67,6 +67,10 @@
"TikTok": "TikTok (TikTok support is coming soon)",
"Bilibili": "Bilibili (Bilibili support is coming soon)",
"Xiaohongshu": "Xiaohongshu (Xiaohongshu support is coming soon)",
"Local file": "Local file"
"Local file": "Local file",
"Play Voice": "Play Voice",
"Voice Example": "This is an example text for testing speech synthesis",
"Synthesizing Voice": "Synthesizing voice, please wait...",
"TTS Provider": "Select the voice synthesis provider"
}
}

View File

@ -67,6 +67,10 @@
"TikTok": "抖音 (TikTok 支持中,敬请期待)",
"Bilibili": "哔哩哔哩 (Bilibili 支持中,敬请期待)",
"Xiaohongshu": "小红书 (Xiaohongshu 支持中,敬请期待)",
"Local file": "本地文件"
"Local file": "本地文件",
"Play Voice": "试听语音合成",
"Voice Example": "这是一段测试语音合成的示例文本",
"Synthesizing Voice": "语音合成中,请稍候...",
"TTS Provider": "语音合成提供商"
}
}