通过蓝牙和Android音频流

2024-05-13 23:49:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我在大学里有一项任务是开发Android应用程序,它可以与Ubuntu(或任何其他Linux发行版)进行通信,并通过PC机和手机上的麦克风和扬声器传输音频。切换通信方向应该在Android上完成,PC上蓝牙端口的监听脚本应该用Python或其他一些轻量级语言编写。它不必是全双工,只有单双工。在

答案是在蓝牙a2dp的Android配置文件中还是有其他东西?在

我对制作简单的Android应用程序很常见。在

非常感谢!在


Tags: 端口答案脚本语言应用程序ubuntulinux音频
1条回答
网友
1楼 · 发布于 2024-05-13 23:49:19

不知道你是否还需要答案,但我正在研究类似的东西。 基本上是在windows平台上使用python从笔记本电脑的麦克风中录制流音频,然后将声音处理为ANC[自动噪声消除]并通过带通滤波器,然后将音频流输出到蓝牙设备。 我希望最终将其移植到智能手机上,但现在用Python进行原型制作要容易得多。在

虽然我还在项目的早期阶段,这里有两张图片可能会有帮助

1) 使用sounddevice将音频从麦克风传输到扬声器

录制外部音频并播放

请参阅此处的soundaudio模块安装详细信息

http://python-sounddevice.readthedocs.org/en/0.3.1/

import sounddevice as sd
duration = 5  # seconds

myrecording = sd.rec(duration * fs, samplerate=fs, channels=2, dtype='float64')

print "Recording Audio"
sd.wait()

print "Audio recording complete , Play Audio"
sd.play(myrecording, fs)

sd.wait()
print "Play Audio Complete"

2) 与蓝牙通信

请参阅此处的详细信息:

https://people.csail.mit.edu/albert/bluez-intro/c212.html


    import bluetooth
    target_name = "My Phone"
    target_address = None
    nearby_devices = bluetooth.discover_devices()

for bdaddr in nearby_devices:
if target_name == bluetooth.lookup_name( bdaddr ):
target_address = bdaddr
break


if target_address is not None:
    print "found target bluetooth device with address ", target_address
else:
    print "could not find target bluetooth device nearby"

我知道我只是引用这些网站的例子,你可以参考这些网站来获得更多的见解。在

一旦我有了一个工作原型,我将尝试张贴在这里,在未来。在

相关问题 更多 >