veni18 commited on
Commit
3cd3eca
·
1 Parent(s): b86c107
Files changed (1) hide show
  1. app.py +23 -6
app.py CHANGED
@@ -1,17 +1,34 @@
1
  import gradio as gr
2
  from transformers import pipeline
 
 
3
 
4
  def greet(sentences1):
5
 
6
- translation = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hu")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
- text_translated=[]
9
- for text in sentences1:
10
- text_translated.append(translation(text))
11
 
12
  #combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
13
 
14
- return text_translated
15
 
16
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
17
  demo.launch()
 
1
  import gradio as gr
2
  from transformers import pipeline
3
+ import requests
4
+ import json
5
 
6
  def greet(sentences1):
7
 
8
+ API_URL = "https://api-inference.huggingface.co/models/openai/whisper-large-v3-turbo"
9
+ headers = {"Authorization": "Bearer hf_api_key"}
10
+
11
+ def query(filename):
12
+ with open(filename, "rb") as f:
13
+ data = f.read()
14
+ response = requests.post(API_URL, headers=headers, data=data)
15
+ return response.json()
16
+
17
+ my_text = query("rawveg7.mp3")
18
+
19
+ sentences = my_text["text"].split(".")
20
+
21
+ return my_text
22
+
23
+ #translation = pipeline("translation", model="Helsinki-NLP/opus-mt-en-hu")
24
 
25
+ #text_translated=[]
26
+ #for text in sentences:
27
+ # text_translated.append(translation(text))
28
 
29
  #combined_text = ' '.join([item['translation_text'] for sublist in text_translated for item in sublist])
30
 
31
+ #return text_translated
32
 
33
+ demo = gr.Interface(fn=greet, inputs="file", outputs="text")
34
  demo.launch()