Jade-Voice/voice.py

14 lines
416 B
Python
Raw Normal View History

import sounddevice as sd
import numpy as np
from bark import generate_audio, SAMPLE_RATE, preload_models
preload_models()
def say(text):
audio_array = generate_audio(text, history_prompt="v2/en_speaker_9")
audio_array = np.expand_dims(audio_array, axis=1)
stream = sd.OutputStream(samplerate=SAMPLE_RATE, channels=1)
stream.start()
stream.write(audio_array)
stream.stop()
stream.close()