transcribe: return all language probabilities if requested (#210)
* transcribe: return all language probabilities if requested If return_all_language_probs is True, TranscriptionInfo structure will have a list of tuples reflecting all language probabilities as returned by the model. * transcribe: fix docstring * transcribe: remove return_all_lang_probs parameter
This commit is contained in:
@@ -6,11 +6,18 @@ from faster_whisper import WhisperModel, decode_audio
|
||||
def test_transcribe(jfk_path):
|
||||
model = WhisperModel("tiny")
|
||||
segments, info = model.transcribe(jfk_path, word_timestamps=True)
|
||||
assert info.all_language_probs is not None
|
||||
|
||||
assert info.language == "en"
|
||||
assert info.language_probability > 0.9
|
||||
assert info.duration == 11
|
||||
|
||||
# Get top language info from all results, which should match the
|
||||
# already existing metadata
|
||||
top_lang, top_lang_score = info.all_language_probs[0]
|
||||
assert info.language == top_lang
|
||||
assert abs(info.language_probability - top_lang_score) < 1e-16
|
||||
|
||||
segments = list(segments)
|
||||
|
||||
assert len(segments) == 1
|
||||
|
||||
Reference in New Issue
Block a user