Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,8 +37,12 @@ async def generate1(prompt):
|
|
| 37 |
output = ""
|
| 38 |
for response in stream:
|
| 39 |
output += response.token.text
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
communicate = edge_tts.Communicate(output)
|
| 44 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
|
@@ -64,8 +68,12 @@ async def generate2(prompt):
|
|
| 64 |
output = ""
|
| 65 |
for response in stream:
|
| 66 |
output += response.token.text
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
communicate = edge_tts.Communicate(output)
|
| 71 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
|
@@ -91,8 +99,12 @@ async def generate3(prompt):
|
|
| 91 |
output = ""
|
| 92 |
for response in stream:
|
| 93 |
output += response.token.text
|
| 94 |
-
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 96 |
|
| 97 |
communicate = edge_tts.Communicate(output)
|
| 98 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
|
|
|
| 37 |
output = ""
|
| 38 |
for response in stream:
|
| 39 |
output += response.token.text
|
| 40 |
+
|
| 41 |
+
# Clean the output to remove extraneous characters
|
| 42 |
+
output = re.sub(r'[\s/]+', ' ', output).strip()
|
| 43 |
+
output = re.sub(r'\s*$', '', output).strip() # Remove trailing whitespaces
|
| 44 |
+
if output.endswith(' s'):
|
| 45 |
+
output = output[:-2].strip() # Remove trailing ' s'
|
| 46 |
|
| 47 |
communicate = edge_tts.Communicate(output)
|
| 48 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
|
|
|
| 68 |
output = ""
|
| 69 |
for response in stream:
|
| 70 |
output += response.token.text
|
| 71 |
+
|
| 72 |
+
# Clean the output to remove extraneous characters
|
| 73 |
+
output = re.sub(r'[\s/]+', ' ', output).strip()
|
| 74 |
+
output = re.sub(r'\s*$', '', output).strip() # Remove trailing whitespaces
|
| 75 |
+
if output.endswith(' s'):
|
| 76 |
+
output = output[:-2].strip() # Remove trailing ' s'
|
| 77 |
|
| 78 |
communicate = edge_tts.Communicate(output)
|
| 79 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
|
|
|
| 99 |
output = ""
|
| 100 |
for response in stream:
|
| 101 |
output += response.token.text
|
| 102 |
+
|
| 103 |
+
# Clean the output to remove extraneous characters
|
| 104 |
+
output = re.sub(r'[\s/]+', ' ', output).strip()
|
| 105 |
+
output = re.sub(r'\s*$', '', output).strip() # Remove trailing whitespaces
|
| 106 |
+
if output.endswith(' s'):
|
| 107 |
+
output = output[:-2].strip() # Remove trailing ' s'
|
| 108 |
|
| 109 |
communicate = edge_tts.Communicate(output)
|
| 110 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|