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:
Ozan Caglayan
2023-05-09 13:53:47 +01:00
committed by GitHub
parent 5d8f3e2d90
commit 91f948b0d6
2 changed files with 17 additions and 3 deletions

View File

@@ -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