Spaces:
Edmond98
/
Running on A100

vineelpratap commited on
Commit
d4e3aaf
1 Parent(s): b226b85

Update asr.py

Browse files
Files changed (1) hide show
  1. asr.py +13 -4
asr.py CHANGED
@@ -66,10 +66,19 @@ model = Wav2Vec2ForCTC.from_pretrained(MODEL_ID)
66
  # )
67
 
68
 
69
- def transcribe(
70
- audio_data, lang="eng (English)"
71
- ):
72
- sr, audio_samples = audio_data
 
 
 
 
 
 
 
 
 
73
 
74
  lang_code = lang.split()[0]
75
  processor.tokenizer.set_target_lang(lang_code)
 
66
  # )
67
 
68
 
69
+ def transcribe(audio_data, lang="eng (English)"):
70
+
71
+ if isinstance(audio_data, tuple):
72
+ # microphone
73
+ sr, audio_samples = audio_data
74
+ print("case1", audio_samples[:5])
75
+ assert sr == ASR_SAMPLING_RATE, "Invalid sampling rate"
76
+ else:
77
+ # file upload
78
+ isinstance(audio_data, str)
79
+ print("case2 1", audio_data)
80
+ audio_samples = librosa.load(audio_fp, sr=ASR_SAMPLING_RATE, mono=True)[0]
81
+ print("case2", audio_samples[:5])
82
 
83
  lang_code = lang.split()[0]
84
  processor.tokenizer.set_target_lang(lang_code)