Skip to content

Commit 88a72c0

Browse files
committed
v1.3.0 audio format support
1 parent 671f442 commit 88a72c0

File tree

7 files changed

+114
-323
lines changed

7 files changed

+114
-323
lines changed

README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,6 @@ Access `http://localhost:7000` to experience the interactive demo
102102

103103
> 🔍 Complete API documentation is available via the web interface after local deployment
104104
105-
### 🧪 Stress Testing
106-
```bash
107-
# Basic test
108-
python pressure_test.py
109-
110-
# Custom test example
111-
python pressure_test.py -n 50 -c 10 -t long -s
112-
```
113-
114-
**Parameter Explanation**:
115-
- `-n` Total requests
116-
- `-c` Concurrency count
117-
- `-t` Text length (short/medium/long)
118-
- `-s` Save generated audio
119-
120105
## 🤝 Contributing
121106

122107
We welcome all forms of contributions! You can participate by:

README_CN.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,6 @@ python main.py
103103

104104
> 🔍 完整 API 文档可在本地部署后通过 Web 界面查看
105105
106-
### 🧪 压力测试
107-
```bash
108-
# 基础测试
109-
python pressure_test.py
110-
111-
# 自定义测试示例
112-
python pressure_test.py -n 50 -c 10 -t long -s
113-
```
114-
115-
**参数说明**
116-
- `-n` 总请求数
117-
- `-c` 并发数
118-
- `-t` 文本长度 (short/medium/long)
119-
- `-s` 保存生成音频
120-
121106
## 🤝 参与贡献
122107

123108
我们欢迎所有形式的贡献!您可以通过以下方式参与:

pressure_test.py

Lines changed: 0 additions & 268 deletions
This file was deleted.

server/handlers.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,17 @@ async def handle_openai_speech(request: web.Request, queue, session=None) -> web
153153
'wav': 'audio/wav',
154154
'pcm': 'audio/pcm'
155155
}
156-
content_type = format_mapping.get(body['response_format'], 'audio/mpeg')
156+
requested_format = body['response_format'].lower()
157+
if requested_format not in format_mapping:
158+
return web.Response(
159+
text=json.dumps({
160+
"error": f"Unsupported response format: {requested_format}. Supported formats are: {', '.join(format_mapping.keys())}"
161+
}),
162+
status=400,
163+
content_type="application/json"
164+
)
165+
content_type = format_mapping[requested_format]
166+
openai_fm_data['format'] = requested_format
157167

158168
# Create response future
159169
response_future = asyncio.Future()
@@ -209,6 +219,10 @@ async def process_tts_request(task_data: Dict[str, Any], session) -> web.Respons
209219
# Add generation ID to request data
210220
task_data['data']['generation'] = str(uuid.uuid4())
211221

222+
# Ensure format is properly set in request data
223+
if 'format' in task_data['data']:
224+
logger.info(f"Requesting audio in format: {task_data['data']['format']}")
225+
212226
request_kwargs = {
213227
"data": task_data['data'],
214228
"headers": _get_headers(),

0 commit comments

Comments
 (0)