Spaces:
Running
Running
zach
commited on
Commit
·
c8f7e68
1
Parent(s):
e431b2b
Clean up doc strings
Browse files
src/integrations/anthropic_api.py
CHANGED
@@ -11,7 +11,7 @@ Key Features:
|
|
11 |
- Provides detailed logging for debugging and error tracking.
|
12 |
|
13 |
Classes:
|
14 |
-
- AnthropicConfig: Immutable configuration for interacting with the
|
15 |
- AnthropicError: Custom exception for Anthropic API-related errors.
|
16 |
|
17 |
Functions:
|
|
|
11 |
- Provides detailed logging for debugging and error tracking.
|
12 |
|
13 |
Classes:
|
14 |
+
- AnthropicConfig: Immutable configuration for interacting with the Anthropic API.
|
15 |
- AnthropicError: Custom exception for Anthropic API-related errors.
|
16 |
|
17 |
Functions:
|
src/integrations/elevenlabs_api.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
"""
|
2 |
elevenlabs_api.py
|
3 |
|
4 |
-
This file defines the interaction with the ElevenLabs TTS API using the ElevenLabs Python SDK.
|
5 |
It includes functionality for API request handling and processing API responses.
|
6 |
|
7 |
Key Features:
|
@@ -11,11 +11,11 @@ Key Features:
|
|
11 |
- Provides detailed logging for debugging and error tracking.
|
12 |
|
13 |
Classes:
|
14 |
-
- ElevenLabsConfig: Immutable configuration for interacting with
|
15 |
- ElevenLabsError: Custom exception for ElevenLabs API-related errors.
|
16 |
|
17 |
Functions:
|
18 |
-
- text_to_speech_with_elevenlabs:
|
19 |
"""
|
20 |
|
21 |
# Standard Library Imports
|
|
|
1 |
"""
|
2 |
elevenlabs_api.py
|
3 |
|
4 |
+
This file defines the interaction with the ElevenLabs text-to-speech (TTS) API using the ElevenLabs Python SDK.
|
5 |
It includes functionality for API request handling and processing API responses.
|
6 |
|
7 |
Key Features:
|
|
|
11 |
- Provides detailed logging for debugging and error tracking.
|
12 |
|
13 |
Classes:
|
14 |
+
- ElevenLabsConfig: Immutable configuration for interacting with Elevenlabs' TTS API.
|
15 |
- ElevenLabsError: Custom exception for ElevenLabs API-related errors.
|
16 |
|
17 |
Functions:
|
18 |
+
- text_to_speech_with_elevenlabs: synthesizes speech from text using ElevenLabs' TTS API.
|
19 |
"""
|
20 |
|
21 |
# Standard Library Imports
|
src/integrations/hume_api.py
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
"""
|
2 |
hume_api.py
|
3 |
|
4 |
-
This file defines the interaction with the Hume TTS API
|
5 |
-
It includes functionality for
|
6 |
|
7 |
Key Features:
|
8 |
- Encapsulates all logic related to the Hume TTS API.
|
@@ -11,11 +11,11 @@ Key Features:
|
|
11 |
- Provides detailed logging for debugging and error tracking.
|
12 |
|
13 |
Classes:
|
14 |
-
- HumeConfig: Immutable configuration for interacting with
|
15 |
- HumeError: Custom exception for Hume API-related errors.
|
16 |
|
17 |
Functions:
|
18 |
-
- text_to_speech_with_hume:
|
19 |
"""
|
20 |
|
21 |
# Standard Library Imports
|
@@ -104,7 +104,9 @@ def text_to_speech_with_hume(prompt: str, text: str) -> bytes:
|
|
104 |
|
105 |
request_body = {
|
106 |
'text': text,
|
107 |
-
'voice': {
|
|
|
|
|
108 |
}
|
109 |
|
110 |
try:
|
@@ -119,14 +121,12 @@ def text_to_speech_with_hume(prompt: str, text: str) -> bytes:
|
|
119 |
logger.error(f'Hume TTS API Error: {response.status_code} - {response.text[:200]}... (truncated)')
|
120 |
raise HumeError(f'Hume TTS API responded with status {response.status_code}: {response.text[:200]}')
|
121 |
|
122 |
-
# Process audio
|
123 |
if response.headers.get('Content-Type', '').startswith('audio/'):
|
124 |
audio = response.content # Raw binary audio data
|
125 |
logger.info(f'Received audio data from Hume ({len(audio)} bytes).')
|
126 |
-
|
127 |
return audio
|
128 |
|
129 |
-
# Unexpected content type
|
130 |
raise HumeError(f'Unexpected Content-Type: {response.headers.get("Content-Type", "Unknown")}')
|
131 |
|
132 |
except Exception as e:
|
|
|
1 |
"""
|
2 |
hume_api.py
|
3 |
|
4 |
+
This file defines the interaction with the Hume text-to-speech (TTS) API.
|
5 |
+
It includes functionality for API request handling and processing API responses.
|
6 |
|
7 |
Key Features:
|
8 |
- Encapsulates all logic related to the Hume TTS API.
|
|
|
11 |
- Provides detailed logging for debugging and error tracking.
|
12 |
|
13 |
Classes:
|
14 |
+
- HumeConfig: Immutable configuration for interacting with Hume's text-to-speech API.
|
15 |
- HumeError: Custom exception for Hume API-related errors.
|
16 |
|
17 |
Functions:
|
18 |
+
- text_to_speech_with_hume: Synthesizes speech from text using Hume's text-to-speech API.
|
19 |
"""
|
20 |
|
21 |
# Standard Library Imports
|
|
|
104 |
|
105 |
request_body = {
|
106 |
'text': text,
|
107 |
+
'voice': {
|
108 |
+
'name': hume_config.random_voice
|
109 |
+
},
|
110 |
}
|
111 |
|
112 |
try:
|
|
|
121 |
logger.error(f'Hume TTS API Error: {response.status_code} - {response.text[:200]}... (truncated)')
|
122 |
raise HumeError(f'Hume TTS API responded with status {response.status_code}: {response.text[:200]}')
|
123 |
|
124 |
+
# Process response audio
|
125 |
if response.headers.get('Content-Type', '').startswith('audio/'):
|
126 |
audio = response.content # Raw binary audio data
|
127 |
logger.info(f'Received audio data from Hume ({len(audio)} bytes).')
|
|
|
128 |
return audio
|
129 |
|
|
|
130 |
raise HumeError(f'Unexpected Content-Type: {response.headers.get("Content-Type", "Unknown")}')
|
131 |
|
132 |
except Exception as e:
|