|
import json |
|
import whisper |
|
import requests |
|
|
|
large_multi = whisper.load_model("large-v3") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_audio(params): |
|
solutions=[] |
|
|
|
params = json.loads(params) |
|
|
|
audio_files = params.get("urls",[]) |
|
if not params.get("normalfileID",[]): |
|
file_ids = [None]*len(audio_files) |
|
else: |
|
file_ids = params.get("normalfileID",[]) |
|
|
|
|
|
|
|
for audio, file_id in zip(audio_files,file_ids): |
|
result_multi = large_multi.transcribe(audio) |
|
text = result_multi['text'] |
|
|
|
answer_dict = {} |
|
answer_dict.update({'url':audio, 'answer':text, "qcUser": None, "normalfileID": file_id}) |
|
solutions.append(answer_dict) |
|
|
|
|
|
|
|
return json.dumps({"solutions":solutions}) |
|
|
|
import gradio as gr |
|
inputt = gr.Textbox(label = "Parameter in json format Eg. {'audio_files':['file1.mp3','file2.wav'], 'api':'https://api.example.com', 'job_id':'1001'}") |
|
outputt = gr.JSON() |
|
|
|
application = gr.Interface(fn=process_audio, inputs = inputt, outputs= outputt, title="Multilingual (Hindi/English) Audio transcription with API Intergration") |
|
application.launch() |