VSPAN commited on
Commit
7ca85b9
·
verified ·
1 Parent(s): f6401c8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -32
app.py CHANGED
@@ -13,19 +13,10 @@ def clean_text(text):
13
  text = emoji.replace_emoji(text, replace='')
14
  return text
15
 
16
- # Get all available voices and filter Russian voices
17
  async def get_voices():
18
  voices = await edge_tts.list_voices()
19
- # Фильтруем только русские голоса
20
- russian_voices = {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices if v['Locale'] == 'ru-RU'}
21
-
22
- # Добавляем новый русский голос, если он не в списке
23
- new_voice_short_name = "YourCustomVoiceShortName" # Замените на реальный ShortName вашего голоса
24
- new_voice_name = "YourCustomVoice - ru-RU (Female)" # Замените на реальное имя вашего голоса
25
- if new_voice_short_name not in [v.split(" - ")[0] for v in russian_voices.keys()]:
26
- russian_voices[new_voice_name] = new_voice_short_name
27
-
28
- return russian_voices
29
 
30
  # Text-to-speech function
31
  async def text_to_speech(text, voice, rate, pitch):
@@ -58,26 +49,6 @@ def tts_interface(text, voice, rate, pitch):
58
  async def create_demo():
59
  voices = await get_voices()
60
 
61
- if not voices:
62
- return gr.Interface(
63
- fn=tts_interface,
64
- inputs=[
65
- gr.Textbox(label="Input Text", lines=5),
66
- gr.Dropdown(choices=[""], label="Select Voice", value=""),
67
- gr.Slider(minimum=-50, maximum=50, value=0, label="Speech Rate Adjustment (%)", step=1),
68
- gr.Slider(minimum=-20, maximum=20, value=0, label="Pitch Adjustment (Hz)", step=1)
69
- ],
70
- outputs=[
71
- gr.Audio(label="Generated Audio", type="filepath"),
72
- gr.Markdown(label="Warning", visible=False)
73
- ],
74
- title="Edge TTS Text-to-Speech",
75
- description="No Russian voices available.",
76
- article="No Russian voices available. Please check your Edge TTS configuration.",
77
- analytics_enabled=False,
78
- allow_flagging="manual"
79
- )
80
-
81
  description = """
82
  Convert text to speech using Edge TTS and explore our advanced Text-to-Video Converter for even more creative possibilities!
83
  """
@@ -96,7 +67,7 @@ async def create_demo():
96
  ],
97
  title="Edge TTS Text-to-Speech",
98
  description=description,
99
- article="Experience the power of Edge TTS for text-to-speech conversion, and explore our advanced Text-to-Video Converter for even more creative possibilities!",
100
  analytics_enabled=False,
101
  allow_flagging="manual"
102
  )
 
13
  text = emoji.replace_emoji(text, replace='')
14
  return text
15
 
16
+ # Get all available voices
17
  async def get_voices():
18
  voices = await edge_tts.list_voices()
19
+ return {f"{v['ShortName']} - {v['Locale']} ({v['Gender']})": v['ShortName'] for v in voices}
 
 
 
 
 
 
 
 
 
20
 
21
  # Text-to-speech function
22
  async def text_to_speech(text, voice, rate, pitch):
 
49
  async def create_demo():
50
  voices = await get_voices()
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  description = """
53
  Convert text to speech using Edge TTS and explore our advanced Text-to-Video Converter for even more creative possibilities!
54
  """
 
67
  ],
68
  title="Edge TTS Text-to-Speech",
69
  description=description,
70
+ article="",
71
  analytics_enabled=False,
72
  allow_flagging="manual"
73
  )