|
import gradio as gr |
|
from transformers import pipeline |
|
import requests |
|
import json |
|
import os |
|
|
|
def speechToText(file): |
|
|
|
api_key = os.getenv("veni18sttts") |
|
API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3-turbo" |
|
headers = {"Authorization": f"Bearer {api_key}"} |
|
|
|
def query(file): |
|
with open(file, "rb") as f: |
|
data = f.read() |
|
response = requests.post(API_URL, headers=headers, data=data) |
|
return response.json() |
|
|
|
my_text = query(file) |
|
|
|
|
|
|
|
return my_text |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
demo = gr.Interface(fn=speechToText, inputs="file", outputs="text") |
|
demo.launch() |