divakaivan commited on
Commit
c6e8353
1 Parent(s): 76fd095

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .gitignore +1 -0
  2. README.md +2 -9
  3. app.py +4 -3
  4. app_old.py +29 -0
  5. requirements.txt +1 -1
.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ .DS_Store
README.md CHANGED
@@ -1,13 +1,6 @@
1
  ---
2
- title: Glaswegian Whisper
3
- emoji: 😻
4
- colorFrom: indigo
5
- colorTo: blue
6
  sdk: gradio
7
  sdk_version: 4.36.1
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
  ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: glaswegian-whisper
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.36.1
 
 
 
6
  ---
 
 
app.py CHANGED
@@ -4,11 +4,12 @@ import gradio as gr
4
  pipe = pipeline(model="divakaivan/whisper-small-hi_test")
5
 
6
  def transcribe(audio):
7
-
 
8
  text = pipe(audio)["text"]
9
  return text
10
 
11
- demo = gr.Interface(
12
  fn=transcribe,
13
  inputs=gr.Audio(type="filepath"),
14
  outputs="text",
@@ -16,4 +17,4 @@ demo = gr.Interface(
16
  description="Realtime demo for Glaswegian speech recognition using a fine-tuned Whisper small model.",
17
  )
18
 
19
- demo.launch(share=True)
 
4
  pipe = pipeline(model="divakaivan/whisper-small-hi_test")
5
 
6
  def transcribe(audio):
7
+ print(audio)
8
+ print(type(audio))
9
  text = pipe(audio)["text"]
10
  return text
11
 
12
+ iface = gr.Interface(
13
  fn=transcribe,
14
  inputs=gr.Audio(type="filepath"),
15
  outputs="text",
 
17
  description="Realtime demo for Glaswegian speech recognition using a fine-tuned Whisper small model.",
18
  )
19
 
20
+ iface.launch(share=True)
app_old.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from st_audiorec import st_audiorec
3
+ from transformers import AutoProcessor, AutoModelForSpeechSeq2Seq
4
+
5
+ processor = AutoProcessor.from_pretrained("openai/whisper-small")
6
+ model = AutoModelForSpeechSeq2Seq.from_pretrained("openai/whisper-small")
7
+
8
+ def transcribe(audio):
9
+
10
+ text = processor.batch_decode(model.generate(processor(audio), num_beams=4), skip_special_tokens=True)
11
+ return text
12
+
13
+ wav_audio_data = st_audiorec()
14
+
15
+ if wav_audio_data is not None:
16
+ # st.audio(wav_audio_data, format='audio/wav')
17
+ st.write("Transcription:")
18
+ st.write(transcribe(wav_audio_data))
19
+
20
+ # Set up the Streamlit app
21
+ st.title("Glaswegian Transcription with Whisper")
22
+ api_key = st.sidebar.text_input("Enter your API key")
23
+
24
+ # Check if API key is provided
25
+ if api_key:
26
+ st.write("API key:", api_key)
27
+ # Add your code here to use the Whisper model for audio transcription
28
+ else:
29
+ st.warning("Please enter your API key in the sidebar.")
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
  transformers
2
  torch
3
- torchvision
 
1
  transformers
2
  torch
3
+ torchvision