File size: 1,047 Bytes
6b8d83a
a83f7f5
3cd3eca
 
62670d0
6b8d83a
62670d0
cf16c11
62670d0
3cd3eca
62670d0
3cd3eca
e5a6da2
 
3cd3eca
 
 
 
5cb2533
3cd3eca
1b92c97
3cd3eca
 
 
 
9613838
3cd3eca
 
 
cf16c11
b86c107
cf16c11
3cd3eca
6b8d83a
62670d0
cf16c11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import gradio as gr
from transformers import pipeline
import requests
import json
import os

def speechToText(file):

    api_key = os.getenv("veni18sttts")  # Itt olvassuk ki a secrets-ből a környezeti változót
    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)

    #sentences = my_text["text"].split(".")

    return my_text

    #translation = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hu")
    
    #text_translated=[]
    #for text in sentences:
    #    text_translated.append(translation(text))

    #combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])

    #return text_translated

demo = gr.Interface(fn=speechToText, inputs="file", outputs="text")
demo.launch()