mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Fix audio type conversion (#259)
* Fix conversion between audio dtypes * Run Pytest in CI * Add pytest tests path in pyproject.toml * Fix usages * Use other PR's test format (more or less) * Support legacy arguments * Fix pyproject.toml and test location * Omit `test` arg in CI, given by pyproject.toml --------- Co-authored-by: Freddy Boulton <alfonsoboulton@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import fastapi
|
||||
from fastrtc import ReplyOnPause, Stream, AlgoOptions, SileroVadOptions
|
||||
from fastrtc.utils import audio_to_bytes
|
||||
from fastrtc.utils import audio_to_bytes, audio_to_float32
|
||||
from openai import OpenAI
|
||||
import logging
|
||||
import time
|
||||
@@ -78,8 +78,8 @@ def echo(audio):
|
||||
)
|
||||
|
||||
for audio_chunk in audio_stream:
|
||||
audio_array = (
|
||||
np.frombuffer(audio_chunk, dtype=np.int16).astype(np.float32) / 32768.0
|
||||
audio_array = audio_to_float32(
|
||||
np.frombuffer(audio_chunk, dtype=np.int16)
|
||||
)
|
||||
yield (24000, audio_array)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user