VSPAN commited on
Commit
9d562d5
·
verified ·
1 Parent(s): f8ca90e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -2,7 +2,15 @@ import gradio as gr
2
  import edge_tts
3
  import asyncio
4
  import tempfile
5
- import os
 
 
 
 
 
 
 
 
6
 
7
  # Get all available voices
8
  async def get_voices():
@@ -16,6 +24,9 @@ async def text_to_speech(text, voice, rate, pitch):
16
  if not voice:
17
  return None, gr.Warning("Please select a voice.")
18
 
 
 
 
19
  voice_short_name = voice.split(" - ")[0]
20
  rate_str = f"{rate:+d}%"
21
  pitch_str = f"{pitch:+d}Hz"
@@ -31,8 +42,6 @@ def tts_interface(text, voice, rate, pitch):
31
  return audio, warning
32
 
33
  # Create Gradio application
34
- import gradio as gr
35
-
36
  async def create_demo():
37
  voices = await get_voices()
38
 
 
2
  import edge_tts
3
  import asyncio
4
  import tempfile
5
+ import re
6
+
7
+ # Функция для очистки текста от нежелательных символов и эмодзи
8
+ def clean_text(text):
9
+ # Удаление указанных символов
10
+ text = re.sub(r'[*_~><]', '', text)
11
+ # Удаление эмодзи
12
+ text = re.sub(r'[^\x00-\x7F]+', '', text)
13
+ return text
14
 
15
  # Get all available voices
16
  async def get_voices():
 
24
  if not voice:
25
  return None, gr.Warning("Please select a voice.")
26
 
27
+ # Очистка текста
28
+ text = clean_text(text)
29
+
30
  voice_short_name = voice.split(" - ")[0]
31
  rate_str = f"{rate:+d}%"
32
  pitch_str = f"{pitch:+d}Hz"
 
42
  return audio, warning
43
 
44
  # Create Gradio application
 
 
45
  async def create_demo():
46
  voices = await get_voices()
47