FloweryAPI
FloweryAPI
Main class for interacting with the Flowery API
Attributes:
Name | Type | Description |
---|---|---|
config |
FloweryAPIConfig
|
Configuration object for the API |
adapter |
RestAdapter
|
Adapter for making HTTP requests |
Source code in pyflowery/pyflowery.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
fetch_tts(text, voice=None, translate=False, silence=0, audio_format='mp3', speed=1.0)
async
Fetch a TTS audio file from the Flowery API
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text |
str
|
The text to convert to speech |
required |
voice |
Voice | str
|
The voice to use for the speech |
None
|
translate |
bool
|
Whether to translate the text |
False
|
silence |
int
|
Number of seconds of silence to add to the end of the audio |
0
|
audio_format |
str
|
The audio format to return |
'mp3'
|
speed |
float
|
The speed of the speech |
1.0
|
Raises:
Type | Description |
---|---|
ValueError
|
Raised when the provided text is too long and |
TooManyRequests
|
Raised when the Flowery API returns a 429 status code |
ClientError
|
Raised when the Flowery API returns a 4xx status code |
InternalServerError
|
Raised when the Flowery API returns a 5xx status code |
ResponseError
|
Raised when the Flowery API returns an empty response or a response with an unexpected format |
RetryLimitExceeded
|
Raised when the retry limit defined in the |
Returns:
Name | Type | Description |
---|---|---|
bytes |
bytes
|
The audio file in bytes |
Source code in pyflowery/pyflowery.py
fetch_voice(voice_id)
async
Fetch a voice from the Flowery API. This method bypasses the cache and directly queries the Flowery API. You should usually use get_voices()
instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
voice_id |
str
|
The ID of the voice |
required |
Raises:
Type | Description |
---|---|
ValueError
|
Raised when the voice is not found |
TooManyRequests
|
Raised when the Flowery API returns a 429 status code |
ClientError
|
Raised when the Flowery API returns a 4xx status code |
InternalServerError
|
Raised when the Flowery API returns a 5xx status code |
RetryLimitExceeded
|
Raised when the retry limit defined in the |
Returns:
Name | Type | Description |
---|---|---|
Voice |
Voice
|
The voice |
Source code in pyflowery/pyflowery.py
fetch_voices()
async
Fetch a list of voices from the Flowery API
Raises:
Type | Description |
---|---|
TooManyRequests
|
Raised when the Flowery API returns a 429 status code |
ClientError
|
Raised when the Flowery API returns a 4xx status code |
InternalServerError
|
Raised when the Flowery API returns a 5xx status code |
ResponseError
|
Raised when the Flowery API returns an empty response or a response with an unexpected format |
RetryLimitExceeded
|
Raised when the retry limit defined in the |
Returns:
Type | Description |
---|---|
AsyncGenerator[Voice, None]
|
AsyncGenerator[Voice, None]: A generator of Voices |
Source code in pyflowery/pyflowery.py
get_voices(voice_id=None, name=None)
Get a set of voices from the cache.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
voice_id |
str
|
The ID of the voice |
None
|
name |
str
|
The name of the voice |
None
|
Returns:
Type | Description |
---|---|
Tuple[Voice, ...] | None
|
Tuple[Voice] | None: A tuple of Voice objects if found, otherwise None |