-
Notifications
You must be signed in to change notification settings - Fork 4
Add Deepgram Streaming Diarization #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dbrkn
wants to merge
18
commits into
main
Choose a base branch
from
berkin/streaming-diarization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
22eedde
update benchmarks.md
9eaa8a7
Refactor
d3c92cd
Refactor
f0e2dec
add deepgram streaming diarization pipeline
8037e29
update benchmarks
adc13fe
Refactor
3bda1d5
refactor
e9b314c
.
1dbc5fe
fix api key
6cbd429
Merge branch 'main' into berkin/streaming-diarization
dbrkn 28da8ec
Add Deepgram streaming orchestration pipeline
6c6a394
remove streaming diarization
62870c1
Merge branch 'main' into berkin/streaming-diarization
EduardoPach 913b5b7
Merge main into berkin/streaming-diarization
d350e0d
Fix merge conflict
0b5dcfc
fix pipeline type
5342074
Merge origin/main into berkin/streaming-diarization
cad24b6
Raise error when speaker diarization data is not available in orchest…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| callhome_english: | ||
| dataset_id: argmaxinc/callhome-english | ||
| split: test | ||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Dummy argument to make the config file valid | ||
| cpwer: | ||
| skip_overlap: false |
9 changes: 9 additions & 0 deletions
9
config/pipeline_configs/DeepgramStreamingOrchestrationPipeline.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| DeepgramStreamingOrchestrationPipeline: | ||
| pipeline_config: | ||
| sample_rate: 16000 | ||
| channels: 1 | ||
| sample_width: 2 | ||
| realtime_resolution: 0.020 | ||
| model_version: "nova-3" | ||
| enable_diarization: true | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
src/openbench/pipeline/orchestration/orchestration_deepgram_streaming.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # For licensing see accompanying LICENSE.md file. | ||
| # Copyright (C) 2025 Argmax, Inc. All Rights Reserved. | ||
|
|
||
| import numpy as np | ||
| from pydantic import Field | ||
|
|
||
| from ...dataset import OrchestrationSample | ||
| from ...pipeline import Pipeline, PipelineConfig, register_pipeline | ||
| from ...pipeline_prediction import Transcript, Word | ||
| from ...types import PipelineType | ||
| from ..streaming_transcription.deepgram import DeepgramApi | ||
| from .common import OrchestrationOutput | ||
|
|
||
|
|
||
| class DeepgramStreamingOrchestrationPipelineConfig(PipelineConfig): | ||
| sample_rate: int = Field(default=16000, description="Sample rate of the audio") | ||
| channels: int = Field(default=1, description="Number of audio channels") | ||
| sample_width: int = Field(default=2, description="Sample width in bytes") | ||
| realtime_resolution: float = Field(default=0.020, description="Real-time resolution for streaming") | ||
| model_version: str = Field( | ||
| default="nova-3", description=("The model to use for real-time transcription with diarization") | ||
| ) | ||
| enable_diarization: bool = Field(default=True, description="Whether to enable speaker diarization") | ||
|
|
||
|
|
||
| @register_pipeline | ||
| class DeepgramStreamingOrchestrationPipeline(Pipeline): | ||
| _config_class = DeepgramStreamingOrchestrationPipelineConfig | ||
| pipeline_type = PipelineType.ORCHESTRATION | ||
|
|
||
| def build_pipeline(self): | ||
| """Build Deepgram streaming API with diarization enabled.""" | ||
| # Create a modified config for the streaming API | ||
| from types import SimpleNamespace | ||
|
|
||
| api_config = SimpleNamespace( | ||
| channels=self.config.channels, | ||
| sample_width=self.config.sample_width, | ||
| sample_rate=self.config.sample_rate, | ||
| realtime_resolution=self.config.realtime_resolution, | ||
| model_version=self.config.model_version, | ||
| enable_diarization=self.config.enable_diarization, | ||
| ) | ||
|
|
||
| pipeline = DeepgramApi(api_config) | ||
| return pipeline | ||
|
|
||
| def parse_input(self, input_sample: OrchestrationSample): | ||
| """Convert audio waveform to bytes for streaming.""" | ||
| y = input_sample.waveform | ||
| y_int16 = (y * 32767).astype(np.int16) | ||
| audio_data_byte = y_int16.T.tobytes() | ||
| return audio_data_byte | ||
|
|
||
| def parse_output(self, output) -> OrchestrationOutput: | ||
| """Parse output to extract transcription and diarization.""" | ||
| # Extract words with speaker info if diarization enabled | ||
| words = [] | ||
|
|
||
| if "words_with_speakers" in output and output["words_with_speakers"]: | ||
| # This comes from diarization-enabled streaming | ||
| for word_info in output["words_with_speakers"]: | ||
| words.append( | ||
| Word( | ||
| word=word_info.get("word", ""), | ||
| start=word_info.get("start"), | ||
| end=word_info.get("end"), | ||
| speaker=word_info.get("speaker"), | ||
| ) | ||
| ) | ||
| elif "model_timestamps_confirmed" in output and output["model_timestamps_confirmed"]: | ||
| # Fallback to regular transcription without speaker | ||
| for timestamp_group in output["model_timestamps_confirmed"]: | ||
| for word_info in timestamp_group: | ||
| if "word" in word_info: | ||
| words.append( | ||
| Word( | ||
| word=word_info.get("word", ""), | ||
| start=word_info.get("start"), | ||
| end=word_info.get("end"), | ||
| speaker=None, | ||
| ) | ||
| ) | ||
|
|
||
| # Create final transcript with speaker-attributed words | ||
| transcript = Transcript(words=words) | ||
|
|
||
| return OrchestrationOutput( | ||
| prediction=transcript, | ||
| transcription_output=None, | ||
| diarization_output=None, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.