Spaces:
Runtime error
Runtime error
Commit
·
a331c7b
1
Parent(s):
454ef36
Add audiooutput
Browse files
app.py
CHANGED
|
@@ -94,6 +94,10 @@ file_list_loaded = ''
|
|
| 94 |
chunk_size = 500
|
| 95 |
chunk_overlap = 300
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
def load_single_document(file_path: str) -> List[Document]:
|
| 98 |
ext = "." + file_path.rsplit(".", 1)[-1]
|
| 99 |
if ext in LOADER_MAPPING:
|
|
@@ -245,6 +249,7 @@ def get_azure_access_token():
|
|
| 245 |
|
| 246 |
|
| 247 |
def text_to_speech_2(text):
|
|
|
|
| 248 |
access_token = get_azure_access_token()
|
| 249 |
voice_name='en-US-AriaNeural'
|
| 250 |
if not access_token:
|
|
@@ -272,6 +277,8 @@ def text_to_speech_2(text):
|
|
| 272 |
with open('sample-' + timestr + '.wav', 'wb') as audio:
|
| 273 |
audio.write(response.content)
|
| 274 |
print ("File Name ", audio.name)
|
|
|
|
|
|
|
| 275 |
except requests.exceptions.RequestException as e:
|
| 276 |
print(f"Error: {e}")
|
| 277 |
return None
|
|
@@ -427,12 +434,16 @@ def chathmi(message, history):
|
|
| 427 |
# yield history
|
| 428 |
|
| 429 |
def chathmi2(message, history):
|
|
|
|
| 430 |
try:
|
| 431 |
output = agent.run(message)
|
| 432 |
time.sleep(0.3)
|
| 433 |
print("History: ", history)
|
| 434 |
response = output
|
| 435 |
yield response
|
|
|
|
|
|
|
|
|
|
| 436 |
except Exception as e:
|
| 437 |
print("error:", e)
|
| 438 |
|
|
|
|
| 94 |
chunk_size = 500
|
| 95 |
chunk_overlap = 300
|
| 96 |
|
| 97 |
+
global Audio_output
|
| 98 |
+
Audio_output = []
|
| 99 |
+
|
| 100 |
+
|
| 101 |
def load_single_document(file_path: str) -> List[Document]:
|
| 102 |
ext = "." + file_path.rsplit(".", 1)[-1]
|
| 103 |
if ext in LOADER_MAPPING:
|
|
|
|
| 249 |
|
| 250 |
|
| 251 |
def text_to_speech_2(text):
|
| 252 |
+
global Audio_output
|
| 253 |
access_token = get_azure_access_token()
|
| 254 |
voice_name='en-US-AriaNeural'
|
| 255 |
if not access_token:
|
|
|
|
| 277 |
with open('sample-' + timestr + '.wav', 'wb') as audio:
|
| 278 |
audio.write(response.content)
|
| 279 |
print ("File Name ", audio.name)
|
| 280 |
+
print (audio)
|
| 281 |
+
Audio_output = audio.name
|
| 282 |
except requests.exceptions.RequestException as e:
|
| 283 |
print(f"Error: {e}")
|
| 284 |
return None
|
|
|
|
| 434 |
# yield history
|
| 435 |
|
| 436 |
def chathmi2(message, history):
|
| 437 |
+
global Audio_output
|
| 438 |
try:
|
| 439 |
output = agent.run(message)
|
| 440 |
time.sleep(0.3)
|
| 441 |
print("History: ", history)
|
| 442 |
response = output
|
| 443 |
yield response
|
| 444 |
+
if Audio_output is not []:
|
| 445 |
+
yield Audio_output
|
| 446 |
+
Audio_output = []
|
| 447 |
except Exception as e:
|
| 448 |
print("error:", e)
|
| 449 |
|