genai_service / utils.py
ahmed-eisa's picture
added ausio generation
c0a983b
raw
history blame
267 Bytes
from io import BytesIO
import soundfile
import numpy as np
def audio_array_to_buffer(audio_array: np.array, sample_rate: int) -> BytesIO:
buffer = BytesIO()
soundfile.write(buffer, audio_array, sample_rate, format="wav")
buffer.seek(0)
return buffer