geoelola commited on
Commit
1ef4b8c
·
1 Parent(s): 3343eb2

whisper tiny

Browse files
Files changed (2) hide show
  1. app.py +41 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import gradio as gr
3
+
4
+ model_id ="openai/whisper-tiny"
5
+ pipe = pipeline("automatic-speech-recognition", model=model_id)
6
+
7
+ def transcribe_speech(filepath):
8
+ output = pipe(
9
+ filepath,
10
+ max_new_tokens=256,
11
+ generate_kwargs={
12
+ "task": "transcribe",
13
+ "language": "spanish",
14
+ }, # update with the language you've fine-tuned on
15
+ chunk_length_s=30,
16
+ batch_size=8,
17
+ )
18
+ return output["text"]
19
+
20
+ demo = gr.Blocks()
21
+
22
+ mic_transcribe = gr.Interface(
23
+ fn=transcribe_speech,
24
+ inputs=gr.Audio(sources="microphone", type="filepath"),
25
+ outputs="textbox",
26
+ )
27
+
28
+ file_transcribe = gr.Interface(
29
+ fn=transcribe_speech,
30
+ inputs=gr.Audio(sources="upload", type="filepath"),
31
+ outputs="textbox",
32
+ )
33
+
34
+
35
+ with demo:
36
+ gr.TabbedInterface(
37
+ [mic_transcribe, file_transcribe],
38
+ ["Transcribir desde el micrófono", "Transcribir desde un archivo"],
39
+ )
40
+
41
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch