M
M
mapleart22021-12-05 01:34:21
Python
mapleart2, 2021-12-05 01:34:21

How to save PCM in binary form to wav in python?

Hello! I deal with one problem. There is an api that synthesizes speech:
61abeb9dc82c2923233430.png
I did it according to the instructions and PCM
61abed2e8d568175848855.png
But this is only a part, how to make it so that from the web socket you get more than one first message, but all until it runs out?

async with websockets.connect(uri) as websocket:
        await websocket.send(data)

        sound = await websocket.recv()
        print(f"< {sound}")

        with wave.open('test.wav', 'wb') as wavfile:
            wavfile.setparams((1, 2, 22050, 0, 'NONE', 'not compressed'))
            wavfile.writeframes(sound)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
smetconsulting, 2022-03-01
@smetconsulting

Hello!
Got it? I have an interest in this task of yours.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question