Shubham09 commited on
Commit
74a2d9a
·
1 Parent(s): 530137f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -6,7 +6,7 @@ from transformers import WhisperProcessor, WhisperForConditionalGeneration, Whis
6
  nltk.download("punkt")
7
  from transformers import pipeline
8
  import scipy.io.wavfile
9
-
10
 
11
  model_name = "Shubham09/whisper31filescheck"
12
  processor = WhisperProcessor.from_pretrained(model_name,task="transcribe")
@@ -24,8 +24,14 @@ def load_data(input_file):
24
  if sample_rate !=16000:
25
  speech = librosa.resample(speech, sample_rate,16000)
26
  return speech
 
27
  def write_to_file(input_file):
28
- scipy.io.wavfile.write("microphone-result.wav")
 
 
 
 
 
29
  # with open("microphone-results.wav", "wb") as f:
30
  # f.write(input_file.get_wav_data())
31
  # import base64
@@ -39,8 +45,8 @@ def write_to_file(input_file):
39
  # return (' '.join([s.replace(s[0],s[0].capitalize(),1) for s in sentences]))
40
  pipe = pipeline(model="Shubham09/whisper31filescheck") # change to "your-username/the-name-you-picked"
41
 
42
- def asr_transcript(input_file="microphone-result.wav"):
43
- text = pipe("microphone-result.wav")["text"]
44
  return text
45
 
46
  # speech = load_data(input_file)
 
6
  nltk.download("punkt")
7
  from transformers import pipeline
8
  import scipy.io.wavfile
9
+ import soundfile as sf
10
 
11
  model_name = "Shubham09/whisper31filescheck"
12
  processor = WhisperProcessor.from_pretrained(model_name,task="transcribe")
 
24
  if sample_rate !=16000:
25
  speech = librosa.resample(speech, sample_rate,16000)
26
  return speech
27
+
28
  def write_to_file(input_file):
29
+ fs = 16000
30
+ sf.write("my_Audio_file.flac",input_file, fs)
31
+
32
+
33
+
34
+ #scipy.io.wavfile.write("microphone-result.wav")
35
  # with open("microphone-results.wav", "wb") as f:
36
  # f.write(input_file.get_wav_data())
37
  # import base64
 
45
  # return (' '.join([s.replace(s[0],s[0].capitalize(),1) for s in sentences]))
46
  pipe = pipeline(model="Shubham09/whisper31filescheck") # change to "your-username/the-name-you-picked"
47
 
48
+ def asr_transcript():
49
+ text = pipe("my_Audio_file.flac")["text"]
50
  return text
51
 
52
  # speech = load_data(input_file)