atanu0491 commited on
Commit
cf830a1
·
verified ·
1 Parent(s): b3eca3e

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +30 -1
src/streamlit_app.py CHANGED
@@ -2,6 +2,33 @@ import streamlit as st
2
  import whisper
3
  import tempfile
4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  st.set_page_config(
6
  page_title="IndicASR",
7
  page_icon="✔️",
@@ -31,8 +58,10 @@ if choice == 'English':
31
  # Load Whisper model
32
  model = whisper.load_model("turbo")
33
 
 
 
34
  # Transcribe
35
- result = model.transcribe(audio_path, verbose=False)
36
 
37
  st.subheader("Transcript")
38
  st.write(result["text"])
 
2
  import whisper
3
  import tempfile
4
 
5
+ import subprocess
6
+ import tempfile
7
+ import os
8
+
9
+ st.logo(
10
+ LOGO_URL_LARGE,
11
+ link="https://jadavpuruniversity.in/storage/2021/12/logo-black-o.png",
12
+ icon_image=LOGO_URL_SMALL,
13
+ )
14
+
15
+ def convert_to_wav(input_path):
16
+ tmp_wav = tempfile.NamedTemporaryFile(delete=False, suffix=".wav")
17
+ tmp_wav.close()
18
+
19
+ cmd = [
20
+ "ffmpeg",
21
+ "-y",
22
+ "-i", input_path,
23
+ "-ar", "16000", # sample rate
24
+ "-ac", "1", # mono
25
+ tmp_wav.name
26
+ ]
27
+
28
+ subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
29
+ return tmp_wav.name
30
+
31
+
32
  st.set_page_config(
33
  page_title="IndicASR",
34
  page_icon="✔️",
 
58
  # Load Whisper model
59
  model = whisper.load_model("turbo")
60
 
61
+ wav_path = convert_to_wav(audio_path)
62
+
63
  # Transcribe
64
+ result = model.transcribe(wav_path, verbose=False)
65
 
66
  st.subheader("Transcript")
67
  st.write(result["text"])