marvin.ai.audio
generate_speech
async
¶
Generates speech based on a provided prompt template.
This function uses the OpenAI Audio API to generate speech based on a provided prompt template. The function supports additional arguments for the prompt and the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prompt_template
|
str
|
The template for the prompt. |
required |
prompt_kwargs
|
dict
|
Additional keyword arguments for the prompt. Defaults to None. |
None
|
stream
|
bool
|
Whether to stream the audio. If False, the
audio can not be saved or played until it has all been generated. If
True, |
True
|
model_kwargs
|
dict
|
Additional keyword arguments for the language model. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Audio |
Audio
|
The response from the OpenAI Audio API, which includes the generated speech. |
speak
¶
Generates audio from text using an AI.
This function uses an AI to generate audio from the provided text. The voice used for the audio can be specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to generate audio from. |
required |
voice
|
Literal['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer']
|
The voice to use for the audio. Defaults to None. |
None
|
stream
|
bool
|
Whether to stream the audio. If False, the
audio can not be saved or played until it has all been generated. If
True, |
True
|
model_kwargs
|
dict
|
Additional keyword arguments for the language model. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Audio |
Audio
|
The generated audio. |
speak_async
async
¶
Generates audio from text using an AI.
This function uses an AI to generate audio from the provided text. The voice used for the audio can be specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to generate audio from. |
required |
voice
|
Literal['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer']
|
The voice to use for the audio. Defaults to None. |
None
|
stream
|
bool
|
Whether to stream the audio. If False, the
audio can not be saved or played until it has all been generated. If
True, |
True
|
model_kwargs
|
dict
|
Additional keyword arguments for the language model. Defaults to None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Audio |
Audio
|
The generated audio. |
speech
¶
Function decorator that generates audio from the wrapped function's return value. The voice used for the audio can be specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable
|
The function to wrap. Defaults to None. |
None
|
voice
|
str
|
The voice to use for the audio. Defaults to None. |
None
|
stream
|
bool
|
Whether to stream the audio. If False, the
audio can not be saved or played until it has all been generated. If
True, |
True
|
Returns:
Name | Type | Description |
---|---|---|
Callable |
Callable
|
The wrapped function. |
transcribe
¶
Transcribes audio from a file.
This function converts audio from a file to text.
transcribe_async
async
¶
Transcribes audio from a file.
This function converts audio from a file to text.