Model
TTSVoice
module-attribute
TTSModelSettings 语音枚举的可导出类型
TTSModelSettings
dataclass
TTS(文本转语音)模型的设置。
Source code in agents/voice/model.py
voice
class-attribute
instance-attribute
voice: TTSVoice | None = None
用于 TTS 模型的语音。如果未提供,将使用相应模型的默认语音。
transform_data
class-attribute
instance-attribute
用于转换 TTS 模型数据的函数。如果你希望结果音频流已经具有特定形状,这会很有用。
instructions
class-attribute
instance-attribute
instructions: str = 'You will receive partial sentences. Do not complete the sentence just read out the text.'
用于 TTS 模型的指令。如果你想控制音频输出的语气,这会很有用。
text_splitter
class-attribute
instance-attribute
text_splitter: Callable[[str], tuple[str, str]] = get_sentence_based_splitter()
用于将文本分割成块的函数。如果你希望在将文本发送到 TTS 模型之前就将其分块,而不是等到整个文本处理完毕,这会很有用。
TTSModel
Bases: ABC
可以将文本转换为音频输出的文本转语音模型。
Source code in agents/voice/model.py
run
abstractmethod
run(text: str, settings: TTSModelSettings) -> AsyncIterator[bytes]
给定一个文本字符串,生成 PCM 格式的音频字节流。
参数
text: 要转换为音频的文本。
返回
PCM 格式音频字节的异步迭代器。
StreamedTranscriptionSession
Bases: ABC
音频输入的流式转录会话。
Source code in agents/voice/model.py
transcribe_turns
abstractmethod
STTModelSettings
dataclass
语音转文本(STT)模型的设置。
Source code in agents/voice/model.py
STTModel
Bases: ABC
可以将音频输入转换为文本的语音转文本模型。
Source code in agents/voice/model.py
transcribe
abstractmethod
async
transcribe(input: AudioInput, settings: STTModelSettings, trace_include_sensitive_data: bool, trace_include_sensitive_audio_data: bool) -> str
给定音频输入,生成文本转录。
参数
input: 要转录的音频输入。 settings: 转录时使用的设置。 trace_include_sensitive_data: 是否在追踪中包含敏感数据。 trace_include_sensitive_audio_data: 是否在追踪中包含敏感音频数据。
返回
音频输入的文本转录。
Source code in 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
创建一个新的转录会话,你可以向其推送音频,并接收文本转录流。
参数
input: 要转录的音频输入。 settings: 转录时使用的设置。 trace_include_sensitive_data: 是否在追踪中包含敏感数据。 trace_include_sensitive_audio_data: 是否在追踪中包含敏感音频数据。
返回
一个新的转录会话。
Source code in agents/voice/model.py
VoiceModelProvider
Bases: ABC
语音模型提供者的基础接口。
模型提供者负责根据名称创建语音转文本和文本转语音模型。
Source code in agents/voice/model.py
get_stt_model
abstractmethod
get_stt_model(model_name: str | None) -> STTModel