Mutant Neko
Mutant Neko

Reputation: 1

Process real time audio without compiling using pyaudio

I wanted to do real time audio classification, the classification program works perfectly fine.

I tried to pull the data straight from the stream. However, I realize the format of the data input from the streaming and data that we load from recorded file is not the same. I do not know how to process the data straight from the streaming without recording and load the file again.

Can someone help me on this?

I'm using pyaudio library to do the streaming

FORMAT = pyaudio.paInt16 
        CHANNELS = 1
        RATE = 44100
        CHUNK = 1024
        RECORD_SECONDS = 5
        former_name = "test"
        WAVE_OUTPUT_FILENAME = "audio.wav"


        audio = pyaudio.PyAudio()


        stream = audio.open(format=FORMAT, channels=CHANNELS,
                        rate=RATE, input=True,
                        frames_per_buffer=CHUNK)
        # print ("recording...")

        frames = []

        for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
            data = stream.read(CHUNK)
            frames.append(data)

Upvotes: 0

Views: 272

Answers (1)

Brijesh Kalkani
Brijesh Kalkani

Reputation: 851

Try This It's Works For Me

Fist Install This If You Have WINDOWS OS:- pip install pyttsx3 OR If You Have MAC OS:- pip3 install pyttsx3

import pyttsx3

def voicePlay(string):

    engine = pyttsx3.init()
    engine.say(f"{string}") 
    try:
        engine.runAndWait()
    except Exception as e:
        pass
    engine.runAndWait()

Upvotes: 1

Related Questions