【问题标题】:Stream audio commands from Android to Ubuntu and back via Bluetooth将音频命令从 Android 流式传输到 Ubuntu,然后通过蓝牙返回
【发布时间】:2015-10-18 05:18:44
【问题描述】:

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

BluetoothA2dp Android 配置文件中的答案还是其他内容?

我擅长制作简单的 Android 应用。

非常感谢!

【问题讨论】:

    标签: android python ubuntu bluetooth


    【解决方案1】:

    不确定您是否仍然需要答案,但我正在做类似的事情。 基本上在 Windows 平台上使用 python 来记录来自笔记本电脑麦克风的流式音频,然后处理 ANC [自动噪声消除] 的声音并将其通过带通滤波器,然后将音频流输出到蓝牙设备。 我希望最终将其移植到智能手机上,但现在使用 Python 进行原型设计要容易得多。

    虽然我仍处于该项目的早期阶段,但这里有两个可能会有所帮助的图片,

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

    录制外部音频并播放

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

    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"
    

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

    一旦我有了一个可以工作的原型,我以后会尝试在这里发布它。

    【讨论】:

      猜你喜欢
      • 2013-04-27
      • 2015-08-23
      • 2013-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多