【发布时间】:2021-02-15 01:24:58
【问题描述】:
我正在使用 sounddevice 录制音频,我想通过 pygame 通过虚拟音频线播放它,我一直收到此错误 Exception has occurred: error mpg123_seek: Invalid RVA mode. (code 12)
我的代码如下:
import sounddevice as sd
from scipy.io.wavfile import write
import random
import pygame
import time
pygame.init()
pygame.mixer.init(devicename='CABLE Input (VB-Audio Virtual Cable)')
fs = 44100 # Sample rate
seconds = 00.1 # Duration of recording
def main():
for x in range(10000):
number = random.randint(1,9999999)
myrecording = sd.rec(int(seconds * fs), samplerate=fs, channels=2)
sd.wait() # Wait until recording is finished
write(f'output/output{str(number)}.mp3', fs, myrecording) # Save as WAV file `
# PLAY MIC SOUND HERE
pygame.mixer.music.load(f'output/output{str(number)}.mp3') #Load the mp3
pygame.mixer.music.play() #Play it
time.sleep(00.1)
main()
感谢任何帮助。
【问题讨论】: