Spaces:
Runtime error
Runtime error
ASG Models
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -118,7 +118,7 @@ def genrate_speech(text,name_model):
|
|
| 118 |
).waveform.cpu().numpy().reshape(-1)
|
| 119 |
return model.config.sampling_rate,wav
|
| 120 |
|
| 121 |
-
def generate_audio(text,
|
| 122 |
inputs = tokenizer(text, return_tensors="pt")#.input_ids
|
| 123 |
|
| 124 |
speaker_embeddings = None
|
|
@@ -158,17 +158,7 @@ def get_answer_ai(text):
|
|
| 158 |
return response.text
|
| 159 |
|
| 160 |
with gr.Blocks() as demo: # Use gr.Blocks to wrap the entire interface
|
| 161 |
-
with gr.
|
| 162 |
-
gr.Markdown("## AI: محادثة صوتية بالذكاء الاصطناعي باللهجة السعودية")
|
| 163 |
-
with gr.Row(): # Arrange input/output components side-by-side
|
| 164 |
-
with gr.Column():
|
| 165 |
-
text_input = gr.Textbox(label="أدخل أي نص")
|
| 166 |
-
user_audio = gr.Audio(label="صوتك")
|
| 167 |
-
with gr.Row():
|
| 168 |
-
btn = gr.Button("إرسال")
|
| 169 |
-
btn_ai_only = gr.Button("توليد رد الذكاء الاصطناعي فقط")
|
| 170 |
-
|
| 171 |
-
with gr.Column():
|
| 172 |
model_choices = gr.Dropdown(
|
| 173 |
choices=[
|
| 174 |
"asg2024/vits-ar-sa",
|
|
@@ -180,6 +170,17 @@ with gr.Blocks() as demo: # Use gr.Blocks to wrap the entire interface
|
|
| 180 |
label="اختر النموذج",
|
| 181 |
value="asg2024/vits-ar-sa",
|
| 182 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
ai_audio = gr.Audio(label="رد الذكاء الاصطناعي الصوتي")
|
| 184 |
ai_text = gr.Textbox(label="رد الذكاء الاصطناعي النصي")
|
| 185 |
|
|
@@ -220,7 +221,7 @@ with gr.Blocks() as demo: # Use gr.Blocks to wrap the entire interface
|
|
| 220 |
audio_player = gr.Audio(label="أ audio",streaming=True)
|
| 221 |
|
| 222 |
# Update the event binding
|
| 223 |
-
generate_button.click(generate_audio, inputs=[text_input], outputs=audio_player)
|
| 224 |
|
| 225 |
|
| 226 |
|
|
|
|
| 118 |
).waveform.cpu().numpy().reshape(-1)
|
| 119 |
return model.config.sampling_rate,wav
|
| 120 |
|
| 121 |
+
def generate_audio(text,name_model,speaker_id=None):
|
| 122 |
inputs = tokenizer(text, return_tensors="pt")#.input_ids
|
| 123 |
|
| 124 |
speaker_embeddings = None
|
|
|
|
| 158 |
return response.text
|
| 159 |
|
| 160 |
with gr.Blocks() as demo: # Use gr.Blocks to wrap the entire interface
|
| 161 |
+
with gr.Column():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
model_choices = gr.Dropdown(
|
| 163 |
choices=[
|
| 164 |
"asg2024/vits-ar-sa",
|
|
|
|
| 170 |
label="اختر النموذج",
|
| 171 |
value="asg2024/vits-ar-sa",
|
| 172 |
)
|
| 173 |
+
with gr.Tab("Chat AI "):
|
| 174 |
+
gr.Markdown("## AI: محادثة صوتية بالذكاء الاصطناعي باللهجة السعودية")
|
| 175 |
+
with gr.Row(): # Arrange input/output components side-by-side
|
| 176 |
+
with gr.Column():
|
| 177 |
+
text_input = gr.Textbox(label="أدخل أي نص")
|
| 178 |
+
user_audio = gr.Audio(label="صوتك")
|
| 179 |
+
with gr.Row():
|
| 180 |
+
btn = gr.Button("إرسال")
|
| 181 |
+
btn_ai_only = gr.Button("توليد رد الذكاء الاصطناعي فقط")
|
| 182 |
+
|
| 183 |
+
|
| 184 |
ai_audio = gr.Audio(label="رد الذكاء الاصطناعي الصوتي")
|
| 185 |
ai_text = gr.Textbox(label="رد الذكاء الاصطناعي النصي")
|
| 186 |
|
|
|
|
| 221 |
audio_player = gr.Audio(label="أ audio",streaming=True)
|
| 222 |
|
| 223 |
# Update the event binding
|
| 224 |
+
generate_button.click(generate_audio, inputs=[text_input,model_choice], outputs=audio_player)
|
| 225 |
|
| 226 |
|
| 227 |
|