Sandiago21 commited on
Commit
f65e443
1 Parent(s): 6301fc2

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. README.md +3 -9
  2. app.py +54 -0
  3. example.wav +0 -0
  4. requirements.txt +3 -0
README.md CHANGED
@@ -1,12 +1,6 @@
1
  ---
2
- title: Automatic Speech Recognition Spanish
3
- emoji: 🏆
4
- colorFrom: yellow
5
- colorTo: pink
6
- sdk: gradio
7
- sdk_version: 3.39.0
8
  app_file: app.py
9
- pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: automatic-speech-recognition-spanish
 
 
 
 
 
3
  app_file: app.py
4
+ sdk: gradio
5
+ sdk_version: 3.36.0
6
  ---
 
 
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ import gradio as gr
3
+ from transformers import pipeline
4
+
5
+ model_id = "Sandiago21/whisper-large-v2-spanish" # update with your model id
6
+ pipe = pipeline("automatic-speech-recognition", model=model_id)
7
+
8
+
9
+ title = "Automatic Speech Recognition (ASR)"
10
+ description = """
11
+ Demo for automatic speech recognition in Spanish. Demo uses [Sandiago21/whisper-large-v2-spanish](https://huggingface.co/Sandiago21/whisper-large-v2-spanish) checkpoint, which is based on OpenAI's
12
+ [Whisper](https://huggingface.co/openai/whisper-large-v2) model and is fine-tuned in Spanish Audio dataset
13
+ ![Automatic Speech Recognition (ASR)"](https://datasets-server.huggingface.co/assets/huggingface-course/audio-course-images/--/huggingface-course--audio-course-images/train/2/image/image.png "Diagram of Automatic Speech Recognition (ASR)")
14
+ """
15
+
16
+ def transcribe_speech(filepath):
17
+ output = pipe(
18
+ filepath,
19
+ max_new_tokens=256,
20
+ generate_kwargs={
21
+ "task": "transcribe",
22
+ "language": "spanish",
23
+ }, # update with the language you've fine-tuned on
24
+ chunk_length_s=30,
25
+ batch_size=8,
26
+ )
27
+ return output["text"]
28
+
29
+ demo = gr.Blocks()
30
+
31
+ mic_transcribe = gr.Interface(
32
+ fn=transcribe_speech,
33
+ inputs=gr.Audio(source="microphone", type="filepath"),
34
+ outputs=gr.outputs.Textbox(),
35
+ tilte=title,
36
+ description=description,
37
+ )
38
+
39
+ file_transcribe = gr.Interface(
40
+ fn=transcribe_speech,
41
+ inputs=gr.Audio(source="upload", type="filepath"),
42
+ outputs=gr.outputs.Textbox(),
43
+ examples=[["./example.wav"]],
44
+ tilte=title,
45
+ description=description,
46
+ )
47
+
48
+ with demo:
49
+ gr.TabbedInterface(
50
+ [mic_transcribe, file_transcribe],
51
+ ["Transcribe Microphone", "Transcribe Audio File"],
52
+ ),
53
+
54
+ demo.launch()
example.wav ADDED
Binary file (258 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ transformers
2
+ torch
3
+ gradio_client==0.2.7