ufal / whisper_streaming

Whisper realtime streaming for long speech-to-text transcription and translation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

whisper_online_server.py Freezes after few seconds

Sanjay-Ganapathi opened this issue · comments

I would like to express my gratitude for the exceptional project you have developed. Currently, I am hosting the "whisper_online_server.py" script in a cloud environment, where I stream audio from my local computer through the microphone.

However, I have encountered an issue that I am struggling to resolve. For the initial few seconds, the audio transcription process functions as expected, but subsequently, it freezes. I have not made any alterations to the provided code, I dont know why the transription freezes
Here is the client code I am using :

import pyaudio
import socket
import time

# Define audio parameters
audio_format = pyaudio.paInt16
channels = 1
sample_rate = 16000
chunk_size = 1 * sample_rate
# chunk_size = 65536

server_address = <host>
server_port = <port>


audio = pyaudio.PyAudio()


client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect((server_address, server_port))


stream = audio.open(format=audio_format, channels=channels,
                    rate=sample_rate, input=True, frames_per_buffer=chunk_size)

print("Recording and streaming audio...")

try:
    while True:
        audio_data = b""
        audio_data = stream.read(chunk_size)
        client_socket.sendall(audio_data)
        print("Sending audio data to server")

        time.sleep(0.1)


except KeyboardInterrupt:
    print("Recording and streaming stopped.")

# Close the audio stream and the socket
stream.stop_stream()
stream.close()
client_socket.close()
audio.terminate()

I am relatively new to this field, and despite my attempts to adjust the client code, the issue persists. I would greatly appreciate your assistance in resolving this matter or any guidance you may provide to identify the root cause.

Thank you for your time and support.

Hi,
I worry I can't debug your code. Can you try if it works with the netcat client as suggested in README?
The bug can be on many places, this could help you to find it.

Good luck!

Thanks for replying @Gldkslfmsd
Sure I will try and debug.