Skip to content

Commit

Permalink
Update openaiapi.py
Browse files Browse the repository at this point in the history
Fixed an issue where there was noise in the converted audio
  • Loading branch information
john9405 committed Jan 2, 2024
1 parent 9df9d9c commit afdf090
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions openaiapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ def text_to_speech(speechRequest: SpeechRequest):
buffer = wav_buffer
response_format = speechRequest.response_format
if response_format != 'wav':
wav_audio = AudioSegment(
wav_buffer.getvalue(), frame_rate=config.sampling_rate,
sample_width=2, channels=1)
wav_audio = AudioSegment.from_wav(wav_buffer)
wav_audio.frame_rate=config.sampling_rate
buffer = io.BytesIO()
wav_audio.export(buffer, format=response_format)

Expand Down

0 comments on commit afdf090

Please sign in to comment.