fix: return the diarized transcript when it's required in the request #16133
+275
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Handle Deepgram diarized transcript
When using
diarize=truein the request, Deepgram is actually handling it in different ways :speakerproperty towordspeakerproperty toparagraphif present['results']['channel'][0]["alternatives"][0]['paragraphs']['transcript'], if paragraph is present (depending on the use ofparagraph=trueorsmart_format=truein the request).For now, in the
transformation.pyrelated to Deepgram, it's always a non diarized transcript returned (with['results']['channel'][0]["alternatives"][0]['transcript']).This PR add the handling of the diarized transcription and returned it in place of the non diarized one if exist.
It firstly search for diarized result by looking for
speakerproperty in words (because words are always present in the response). If the result have diarization, it will look for the existence ofparagraphsproperty to get the full transcript. Ifparagraphsis absent, it will build the transcript based on thewordsproperties, with taking care of the text formatting (when usingsmart_formatorpunctuationin the request).Relevant issues
Fixes #16095
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🐛 Bug Fix
✅ Test