Pass audio file as microphone input with python

人走茶凉 提交于 2021-01-29 15:42:24

问题


I want to make a soundboard program for my friends and myself with a few meme sounds we find funny. I already have a working base with one button, that plays the desired sound. Now I just need to figure out a way how to make the audio play through my microphone (simulate microphone input). I already searched the internet and didn't find the exact solution I was looking for.

Here is the code I already have:

import tkinter as tk
import pygame

root = tk.Tk()
root.title("Soundboard");
root.geometry("720x480");

pygame.mixer.init()

def play():
    pygame.mixer.music.load("sound.mp3")
    pygame.mixer.music.play(loops=0)

play = tk.Button(root, text="Play", font=("Arial", 18), command=play)
play.pack(pady=20)

root.mainloop();

来源:https://stackoverflow.com/questions/65796932/pass-audio-file-as-microphone-input-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!