Update app.py
Browse files
app.py
CHANGED
@@ -59,12 +59,7 @@ async def paragraph_to_speech(text, voice, rate, pitch):
|
|
59 |
silence_durations = []
|
60 |
parts = re.split(r'(SS\d+\.?\d*)', text)
|
61 |
for part in parts:
|
62 |
-
|
63 |
-
match = re.search(r'-?\d+', part)
|
64 |
-
pitch = int(match.group()) #Set pitch to set value as noted in the tag
|
65 |
-
# Remove only the first integer found
|
66 |
-
part = re.sub(r'-?\d+', '', part, count=1).strip() #cut out the pitch int from text part
|
67 |
-
|
68 |
if re.match(r'SS\d+\.?\d*', part): #Check if there is Silence tag
|
69 |
# At the top of your file:
|
70 |
#SILENCE_PATH = Path(__file__).parent.absolute() / "Silence.mp3"
|
@@ -117,10 +112,15 @@ async def paragraph_to_speech(text, voice, rate, pitch):
|
|
117 |
#voice_short_name = (voice or default_voice).split(" - ")[0]
|
118 |
current_voice = (voice or default_voice).split(" - ")[0]
|
119 |
processed_text=part[:]
|
|
|
|
|
|
|
|
|
|
|
120 |
rate_str = f"{current_rate:+d}%"
|
121 |
-
if part[2:4].isdigit():
|
122 |
-
|
123 |
-
|
124 |
pitch_str = f"{current_pitch:+d}Hz"
|
125 |
communicate = edge_tts.Communicate(processed_text, current_voice, rate=rate_str, pitch=pitch_str)
|
126 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
|
|
59 |
silence_durations = []
|
60 |
parts = re.split(r'(SS\d+\.?\d*)', text)
|
61 |
for part in parts:
|
62 |
+
|
|
|
|
|
|
|
|
|
|
|
63 |
if re.match(r'SS\d+\.?\d*', part): #Check if there is Silence tag
|
64 |
# At the top of your file:
|
65 |
#SILENCE_PATH = Path(__file__).parent.absolute() / "Silence.mp3"
|
|
|
112 |
#voice_short_name = (voice or default_voice).split(" - ")[0]
|
113 |
current_voice = (voice or default_voice).split(" - ")[0]
|
114 |
processed_text=part[:]
|
115 |
+
if (re.search(r'-?\d+', part)): #if there are any digit following the voice tag, eg 1F20 or 1F-20
|
116 |
+
match = re.search(r'-?\d+', part)
|
117 |
+
pitch = int(match.group()) #Set pitch to set value as noted in the tag
|
118 |
+
# Remove only the first integer found
|
119 |
+
processed_text = re.sub(r'-?\d+', '', part, count=1).strip() #cut out the pitch int from text part
|
120 |
rate_str = f"{current_rate:+d}%"
|
121 |
+
#if part[2:4].isdigit():
|
122 |
+
# processed_text = part[4:]
|
123 |
+
# pitch = int(part[2:4])
|
124 |
pitch_str = f"{current_pitch:+d}Hz"
|
125 |
communicate = edge_tts.Communicate(processed_text, current_voice, rate=rate_str, pitch=pitch_str)
|
126 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|