BaseTurnAnalyzer
- class pipecat.audio.turn.base_turn_analyzer.EndOfTurnState(*values)[source]
Bases:
Enum
- COMPLETE = 1
- INCOMPLETE = 2
- class pipecat.audio.turn.base_turn_analyzer.BaseTurnAnalyzer(*, sample_rate=None)[source]
Bases:
ABC
Abstract base class for analyzing user end of turn.
This class inherits from BaseObject to leverage its event handling system while still defining an abstract interface through abstract methods.
- Parameters:
sample_rate (int | None)
- property sample_rate: int
Returns the current sample rate.
- Returns:
The effective sample rate for audio processing.
- Return type:
int
- set_sample_rate(sample_rate)[source]
Sets the sample rate for audio processing.
If the initial sample rate was provided, it will use that; otherwise, it sets to the provided sample rate.
- Parameters:
sample_rate (int) – The sample rate to set.
- abstract property speech_triggered: bool
Determines if speech has been detected.
- Returns:
True if speech is triggered, otherwise False.
- Return type:
bool
- abstractmethod append_audio(buffer, is_speech)[source]
Appends audio data for analysis.
- Parameters:
buffer (bytes) – The audio data to append.
is_speech (bool) – Indicates whether the appended audio is speech or not.
- Returns:
The resulting state after appending the audio.
- Return type:
EndOfTurnState
- abstractmethod async analyze_end_of_turn()[source]
Analyzes if an end of turn has occurred based on the audio input.
- Returns:
The result of the end of turn analysis.
- Return type:
EndOfTurnState
- abstractmethod clear()[source]
Reset the turn analyzer to its initial state.