1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Sounddevice plays loud noice instead of speech

Discussão em 'Python' iniciado por Stack, Setembro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to make a script that would take some text and turn it into a speech using edge-tts and then stream it using sounddevice, so that playing audio begins right after edge-tts finished it's job. The problem is that when I run it I hear only short (shorter than the expected output), very loud noice and I don't know why

    Here's how the code look like:

    EDGE_SR = 24000

    async def stream_speak(text, voice="de-DE-SeraphinaMultilingualNeural"):
    communicate = edge_tts.Communicate(text, voice=voice)

    device_info = sd.query_devices(kind='output')
    target_sr = int(device_info['default_samplerate'])
    print(f"Playing at {target_sr} Hz (resampling from {EDGE_SR} Hz)")

    with sd.OutputStream(24000, blocksize=1024, channels=1, dtype="int16") as stream:
    async for chunk in communicate.stream():
    if chunk["type"] == "audio":
    audio = np.frombuffer(chunk["data"], dtype=np.int16)
    if target_sr != EDGE_SR:
    audio = resample_poly(audio, target_sr, EDGE_SR).astype(np.int16)
    stream.write(audio)

    def speak_sync(text):
    asyncio.run(stream_speak(text))

    speak_sync('Hallo, ich kann dich gut hören')


    Does someone know what's wrong? I'd be grateful for any help

    Continue reading...

Compartilhe esta Página