Reputation: 45
import time
import threading
from pygame import mixer
from pygame.mixer import Sound
def play_audio_on_mic(audio_file_name):
def play_audio():
mixer.init(devicename = 'CABLE Input (VB-Audio Virtual Cable)')
mixer.music.load(audio_file_name)
mixer.music.play()
while mixer.music.get_busy():
time.sleep(1)
threading.Thread(target=play_audio).start()
audio = Sound(audio_file_name)
return round(audio.get_length())
Listening to the audio normally before playback, I can tell the quality is impeccable. However, when I play this audio through my virtual microphone using this Python script and VB Cable, the sound quality deteriorates it becomes distorted and strange. You can still understand what is being said, but the quality isn't reliable. Since I'll be playing many audio files and real people will be listening to them, I'm concerned that some recordings might end up with even worse distortions.
I don't understand why so few people on the internet have projects like this. I thought it would be a well-documented topic, but I'm probably dealing with something that hasn’t been widely explored in Python. It's actually a bit hard for me to believe, considering how extensively Python is used!
Upvotes: -2
Views: 39