|
import gradio as gr |
|
from transformers import pipeline |
|
from gradio_client import Client, file |
|
|
|
|
|
def detect_language(file_path): |
|
client = Client("adrien-alloreview/speechbrain-lang-id-voxlingua107-ecapa") |
|
result = client.predict(param_0=file(file_path), api_name="/predict") |
|
language_result = result["label"].split(": ")[1] |
|
if language_result.lower() in ["russian", "belarussian", "ukrainian"]: |
|
selected_language = "russian" |
|
else: |
|
selected_language = "kazakh" |
|
return selected_language |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gradio_app = gr.Interface( |
|
fn=detect_language, |
|
inputs=gr.Audio(sources="upload", type="filepath"), |
|
outputs="text", |
|
title="File Upload Transcription", |
|
description="Upload an audio file to determine language." |
|
) |
|
|
|
if __name__ == "__main__": |
|
gradio_app.launch() |