wasm-speeker-sa / app.py
ASG Models
Update app.py
6cc4283 verified
raw
history blame
906 Bytes
import os
import numpy as np
import gradio as gr
# Use a pipeline as a high-level helper
import requests
from genai_chat_ai import AI,create_chat_session
API_URL = "https://api-inference.huggingface.co/models/asg2024/vits-ar-sa"
api_key = os.environ.get("Id_mode_vits")
headers = {"Authorization": f"Bearer {api_key}"}
def query(text):
payload={"inputs": text}
response = requests.post(API_URL, headers=headers, json=payload)
return response.content
def get_answer_ai(text):
try:
response = AI.send_message(text)
return response.text
except error:
return text
def reverse_audio(text):
text_answer=get_answer_ai(text)
data = query(text_answer)
return data#(16000, np.flipud(data))
demo = gr.Interface(
fn=reverse_audio,
inputs="text",
outputs="audio"
)
if __name__ == "__main__":
demo.launch()