Spaces:
Sleeping
Sleeping
ASG Models
commited on
Commit
•
6cc4283
1
Parent(s):
8c2f5a2
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import numpy as np
|
|
5 |
import gradio as gr
|
6 |
# Use a pipeline as a high-level helper
|
7 |
import requests
|
8 |
-
|
9 |
API_URL = "https://api-inference.huggingface.co/models/asg2024/vits-ar-sa"
|
10 |
api_key = os.environ.get("Id_mode_vits")
|
11 |
headers = {"Authorization": f"Bearer {api_key}"}
|
@@ -15,9 +15,19 @@ def query(text):
|
|
15 |
response = requests.post(API_URL, headers=headers, json=payload)
|
16 |
return response.content
|
17 |
|
|
|
|
|
|
|
|
|
18 |
|
|
|
|
|
|
|
|
|
19 |
def reverse_audio(text):
|
20 |
-
|
|
|
|
|
21 |
return data#(16000, np.flipud(data))
|
22 |
|
23 |
|
|
|
5 |
import gradio as gr
|
6 |
# Use a pipeline as a high-level helper
|
7 |
import requests
|
8 |
+
from genai_chat_ai import AI,create_chat_session
|
9 |
API_URL = "https://api-inference.huggingface.co/models/asg2024/vits-ar-sa"
|
10 |
api_key = os.environ.get("Id_mode_vits")
|
11 |
headers = {"Authorization": f"Bearer {api_key}"}
|
|
|
15 |
response = requests.post(API_URL, headers=headers, json=payload)
|
16 |
return response.content
|
17 |
|
18 |
+
def get_answer_ai(text):
|
19 |
+
try:
|
20 |
+
response = AI.send_message(text)
|
21 |
+
return response.text
|
22 |
|
23 |
+
|
24 |
+
except error:
|
25 |
+
return text
|
26 |
+
|
27 |
def reverse_audio(text):
|
28 |
+
text_answer=get_answer_ai(text)
|
29 |
+
|
30 |
+
data = query(text_answer)
|
31 |
return data#(16000, np.flipud(data))
|
32 |
|
33 |
|