Model
TTSVoice
module-attribute
Exportable type for the TTSModelSettings voice enum
TTSModelSettings
dataclass
Settings for a TTS model.
ソースコード位置: src/agents/voice/model.py
voice
class-attribute
instance-attribute
voice: TTSVoice | None = None
The voice to use for the TTS model. If not provided, the default voice for the respective model will be used.
buffer_size
class-attribute
instance-attribute
The minimal size of the chunks of audio data that are being streamed out.
dtype
class-attribute
instance-attribute
The data type for the audio data to be returned in.
transform_data
class-attribute
instance-attribute
A function to transform the data from the TTS model. This is useful if you want the resulting audio stream to have the data in a specific shape already.
instructions
class-attribute
instance-attribute
instructions: str = "You will receive partial sentences. Do not complete the sentence just read out the text."
The instructions to use for the TTS model. This is useful if you want to control the tone of the audio output.
text_splitter
class-attribute
instance-attribute
text_splitter: Callable[[str], tuple[str, str]] = (
get_sentence_based_splitter()
)
A function to split the text into chunks. This is useful if you want to split the text into chunks before sending it to the TTS model rather than waiting for the whole text to be processed.
TTSModel
Bases: ABC
A text-to-speech model that can convert text into audio output.
ソースコード位置: src/agents/voice/model.py
run
abstractmethod
run(
text: str, settings: TTSModelSettings
) -> AsyncIterator[bytes]
Given a text string, produces a stream of audio bytes, in PCM format.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
text
|
str
|
The text to convert to audio. |
必須 |
戻り値:
| タイプ | デスクリプション |
|---|---|
AsyncIterator[bytes]
|
An async iterator of audio bytes, in PCM format. |
ソースコード位置: src/agents/voice/model.py
StreamedTranscriptionSession
Bases: ABC
A streamed transcription of audio input.
ソースコード位置: src/agents/voice/model.py
transcribe_turns
abstractmethod
Yields a stream of text transcriptions. Each transcription is a turn in the conversation.
This method is expected to return only after close() is called.
STTModelSettings
dataclass
Settings for a speech-to-text model.
ソースコード位置: src/agents/voice/model.py
prompt
class-attribute
instance-attribute
Instructions for the model to follow.
language
class-attribute
instance-attribute
The language of the audio input.
temperature
class-attribute
instance-attribute
The temperature of the model.
STTModel
Bases: ABC
A speech-to-text model that can convert audio input into text.
ソースコード位置: src/agents/voice/model.py
transcribe
abstractmethod
async
transcribe(
input: AudioInput,
settings: STTModelSettings,
trace_include_sensitive_data: bool,
trace_include_sensitive_audio_data: bool,
) -> str
Given an audio input, produces a text transcription.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
input
|
AudioInput
|
The audio input to transcribe. |
必須 |
settings
|
STTModelSettings
|
The settings to use for the transcription. |
必須 |
trace_include_sensitive_data
|
bool
|
Whether to include sensitive data in traces. |
必須 |
trace_include_sensitive_audio_data
|
bool
|
Whether to include sensitive audio data in traces. |
必須 |
戻り値:
| タイプ | デスクリプション |
|---|---|
str
|
The text transcription of the audio input. |
ソースコード位置: src/agents/voice/model.py
create_session
abstractmethod
async
create_session(
input: StreamedAudioInput,
settings: STTModelSettings,
trace_include_sensitive_data: bool,
trace_include_sensitive_audio_data: bool,
) -> StreamedTranscriptionSession
Creates a new transcription session, which you can push audio to, and receive a stream of text transcriptions.
引数:
| 名前 | タイプ | デスクリプション | デフォルト |
|---|---|---|---|
input
|
StreamedAudioInput
|
The audio input to transcribe. |
必須 |
settings
|
STTModelSettings
|
The settings to use for the transcription. |
必須 |
trace_include_sensitive_data
|
bool
|
Whether to include sensitive data in traces. |
必須 |
trace_include_sensitive_audio_data
|
bool
|
Whether to include sensitive audio data in traces. |
必須 |
戻り値:
| タイプ | デスクリプション |
|---|---|
StreamedTranscriptionSession
|
A new transcription session. |
ソースコード位置: src/agents/voice/model.py
VoiceModelProvider
Bases: ABC
The base interface for a voice model provider.
A model provider is responsible for creating speech-to-text and text-to-speech models, given a name.