Merge pull request #1057 from pipecat-ai/aleix/replace-resampy-soxr
improve audio resampling by switching from resampy to soxr
This commit is contained in:
@@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Fixed a type error when using `voice_settings` in `ElevenLabsHttpTTSService`.
|
- Fixed a type error when using `voice_settings` in `ElevenLabsHttpTTSService`.
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
- Replaced audio resampling library `resampy` with `soxr`.
|
||||||
|
|
||||||
## [0.0.53] - 2025-01-18
|
## [0.0.53] - 2025-01-18
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ dependencies = [
|
|||||||
"protobuf~=5.29.3",
|
"protobuf~=5.29.3",
|
||||||
"pydantic~=2.10.5",
|
"pydantic~=2.10.5",
|
||||||
"pyloudnorm~=0.1.1",
|
"pyloudnorm~=0.1.1",
|
||||||
"resampy~=0.4.3"
|
"soxr~=0.5.0"
|
||||||
]
|
]
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ import audioop
|
|||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pyloudnorm as pyln
|
import pyloudnorm as pyln
|
||||||
import resampy
|
import soxr
|
||||||
|
|
||||||
|
|
||||||
def resample_audio(audio: bytes, original_rate: int, target_rate: int) -> bytes:
|
def resample_audio(audio: bytes, original_rate: int, target_rate: int) -> bytes:
|
||||||
if original_rate == target_rate:
|
if original_rate == target_rate:
|
||||||
return audio
|
return audio
|
||||||
audio_data = np.frombuffer(audio, dtype=np.int16)
|
audio_data = np.frombuffer(audio, dtype=np.int16)
|
||||||
resampled_audio = resampy.resample(audio_data, original_rate, target_rate)
|
resampled_audio = soxr.resample(audio_data, original_rate, target_rate)
|
||||||
return resampled_audio.astype(np.int16).tobytes()
|
return resampled_audio.astype(np.int16).tobytes()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ pydantic~=2.8.2
|
|||||||
pyloudnorm~=0.1.1
|
pyloudnorm~=0.1.1
|
||||||
pyht~=0.1.4
|
pyht~=0.1.4
|
||||||
python-dotenv~=1.0.1
|
python-dotenv~=1.0.1
|
||||||
resampy~=0.4.3
|
|
||||||
silero-vad~=5.1
|
silero-vad~=5.1
|
||||||
|
soxr~=0.5.0
|
||||||
together~=1.2.7
|
together~=1.2.7
|
||||||
transformers~=4.44.0
|
transformers~=4.44.0
|
||||||
websockets~=13.1
|
websockets~=13.1
|
||||||
|
|||||||
Reference in New Issue
Block a user