在raspberrypi上录制时,有什么方法可以控制音调或音调?

时间:2019-06-19 07:20:28

标签: python raspberry-pi3 audio-recording

我正在做的项目是使用raspberrypi录制并播放声音。 录制或播放没有问题。但是我想控制用户语音的音调或音调。但是我找不到办法。有没有可以使用这种情况的库? 我使用了pyaudo进行录制,然后使用pygame进行游戏。我也发布了我的代码。谢谢

这是我的记录设置

"""setting for recording"""
CHUNK = 1 #1024 buffer/1 frame
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 48000 #48Khz
RECORD_SECONDS =15 #time to record
WAVE_OUTPUT_FILENAME = "output.wav"
"""setting for recording"""

def recording():
    p = pyaudio.PyAudio()
    stream = p.open(format=FORMAT,
                channels=CHANNELS,
                rate=RATE,
                input=True,
                frames_per_buffer=CHUNK)
    print("Start to record the audio.")

    frames = []
    for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)):
        GPIO.output(22,True)
        data = stream.read(CHUNK, exception_on_overflow = False)
        frames.append(data)

    print("Recording is finished.")
    stream.stop_stream()
    stream.close()
    p.terminate()

    waveFile  = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
    waveFile .setnchannels(CHANNELS)
    waveFile.setsampwidth(p.get_sample_size(FORMAT))
    waveFile.setframerate(RATE)
    waveFile.writeframes(b''.join(frames))
    waveFile.close()

0 个答案:

没有答案