2

I have a transcription server listening for audio on a port on a remote machine. Everything works If I stream a pre-recorded audio file and stream it to the port using netcat

I'm not able to do same using mic as input. I'm trying the following but for some reason audio is not getting streamed or I can't see and transcriptions happening or maybe I'm not sure how to get the response back in python

FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
CHUNK = 4800
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "recordedFile.wav"
device_index = 1
audio = pyaudio.PyAudio()

HOST = 'ip'
PORT = 5000

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))

index = (input())
print("recording via index "+str(index))

stream = audio.open(format=FORMAT, channels=CHANNELS,
                rate=RATE, input=True,input_device_index = 1,
                frames_per_buffer=CHUNK)
print ("recording started")
Recordframes = []

for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
    data = stream.read(CHUNK)
     s.sendall(data)
    Recordframes.append(data)
print ("recording stopped")

Not sure how to get back response or is there some other problem. Using Kaldi's online2-tcp-nnet3-decode-faster in backend

Jaskaran Singh Puri
  • 729
  • 2
  • 11
  • 37

0 Answers0