aceent2 / app.py
wesam0099's picture
Update app.py
e16eb92 verified
import gradio as gr
from transformers import pipeline
# ุชุญู…ูŠู„ ุงู„ู†ู…ูˆุฐุฌ ุงู„ุฌุงู‡ุฒ ู…ู† Hugging Face
accent_classifier = pipeline("audio-classification", model="Yactayo/AccentClassifier")
def classify_accent(audio_path):
try:
results = accent_classifier(audio_path)
top_result = results[0]
label = top_result["label"]
score = round(top_result["score"] * 100, 2)
return f"{label} ({score}%)"
except Exception as e:
return f"Error: {str(e)}"
# ูˆุงุฌู‡ุฉ Gradio
with gr.Blocks() as demo:
gr.Markdown("## ๐ŸŽ™๏ธ ุชุตู†ูŠู ุงู„ู„ู‡ุฌุงุช ุจุงุณุชุฎุฏุงู… AI")
with gr.Row():
audio_input = gr.Audio(type="filepath", label="๐Ÿ”Š ุณุฌู„ ุฃูˆ ุญู…ู‘ู„ ู…ู„ู ุตูˆุชูŠ", sources=["upload", "microphone"])
output_text = gr.Textbox(label="ุงู„ู„ู‡ุฌุฉ ุงู„ู…ุชูˆู‚ุนุฉ")
analyze_btn = gr.Button("๐Ÿ” ุชุญู„ูŠู„ ุงู„ู„ู‡ุฌุฉ")
analyze_btn.click(fn=classify_accent, inputs=audio_input, outputs=output_text)
# ุชุดุบูŠู„ ุงู„ุชุทุจูŠู‚
if __name__ == "__main__":
demo.launch()