当前位置: 首页 > news >正文

python源码:指定麦克风/音响播放歌曲

前言

        我使用pygame实现了指定麦克风/音响播放歌曲的功能,主要目的是解决直播过程的多源声道控制问题。

 

代码 

# 查看自己的音频设备
# 请记住目标音频设备的具体名称
import pygame as mixer
import pygame._sdl2 as sdl2mixer.init() # Initialize the mixer, this will allow the next command to work
print(sdl2.audio.get_audio_device_names(False)) # set to False to return playback(output) devices, set to True to return record(input) devices.
mixer.quit() # Quit the mixer as it's initialized on your main playback device
from pygame import mixer
import time# 使用设备:Voicemeeter In 1 (VB-Audio Voicemeeter VAIO)
# 来负责播放
mixer.init(devicename = 'Voicemeeter In 1 (VB-Audio Voicemeeter VAIO)')
# 播放本地歌曲
mixer.music.load("Reol.MP3") # Load the mp3# 播放接口流式歌曲
# from io import BytesIO
# response = requests.get('http://xxxxxx/wav2wav1')
# audio_data = BytesIO(response.content)
# mixer.music.load(audio_data)mixer.music.play() # Play it# 监测音频是否播放完毕
while mixer.music.get_busy():  # wait for music to finish playingtime.sleep(1)

http://www.mrgr.cn/news/51003.html

相关文章:

  • 电能表预付费系统-标准传输规范(STS)(6)
  • python pip安装requirements.txt依赖与国内镜像
  • Loss:Objects as Points
  • 如何实现弹出式窗口
  • 【量化交易】聚宽安装
  • 深入 IDEA 字节码世界:如何轻松查看 .class 文件?
  • python画图|在三维空间的不同平面上分别绘制不同类型二维图
  • Vivado HLS C/RTL 联合仿真时间
  • Tmux常用操作--云GPU版
  • leetcode解题思路分析(一百六十一)1394 - 1400 题
  • 【C++进阶】封装红黑树实现map和set
  • SpringCloud-持久层框架MyBatis Plus的使用与原理详解
  • 超声波测距
  • 微信小程序-独立分包/分包预下载
  • 13.java面向对象:面向对象的三大特征
  • RK3568平台开发系列讲解(调试篇)如何在procfs创建一个文件与用户空间交互
  • 【Python语言进阶(二)】
  • 舍伍德业务安全架构(Sherwood Applied Business Security Architecture, SABSA)
  • 多线程-进阶(2)CountDownLatchConcurrentHashMapSemaphore
  • 社群相关内容整理及分析