camparchimedes commited on
Commit
91682fa
·
verified ·
1 Parent(s): 934d763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -72,7 +72,14 @@ pipe = pipeline("automatic-speech-recognition", model="NbAiLab/nb-whisper-large"
72
  @spaces.GPU()
73
  def transcribe_audio(audio_file, filepath, batch_size=16, sample_rate=16000):
74
 
75
- waveform, sample_rate = torchaudio.load(str(audio_file)) #3
 
 
 
 
 
 
 
76
  #waveform, sample_rate = torchaudio.load("{filepath}") #2
77
 
78
  # --convert to mono
 
72
  @spaces.GPU()
73
  def transcribe_audio(audio_file, filepath, batch_size=16, sample_rate=16000):
74
 
75
+ if not isinstance(filepath, str):
76
+ raise ValueError("Expected a file path string, but received something else.")
77
+
78
+ # Ensure the file exists before trying to load it
79
+ if not Path(filepath).is_file():
80
+ raise FileNotFoundError(f"The file {filepath} does not exist.")
81
+
82
+ waveform, sample_rate = torchaudio.load(filepath)
83
  #waveform, sample_rate = torchaudio.load("{filepath}") #2
84
 
85
  # --convert to mono