Skip to content

Commit

Permalink
Merge pull request #204 from sorgfresser/v3
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bain authored Apr 30, 2023
2 parents a903e57 + b9c8c50 commit 31a9ec7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion whisperx/asr.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,10 @@ def data(audio, segments):


def detect_language(self, audio: np.ndarray):
segment = log_mel_spectrogram(audio[: N_SAMPLES], padding=0)
if audio.shape[0] < N_SAMPLES:
print("Warning: audio is shorter than 30s, language detection may be inaccurate.")
segment = log_mel_spectrogram(audio[: N_SAMPLES],
padding=0 if audio.shape[0] >= N_SAMPLES else N_SAMPLES - audio.shape[0])
encoder_output = self.model.encode(segment)
results = self.model.model.detect_language(encoder_output)
language_token, language_probability = results[0][0]
Expand Down

0 comments on commit 31a9ec7

Please sign in to comment.