小编amp*_*ata的帖子

从Android中的蓝牙音频设备录制音频

如何在Android中录制配对蓝牙音频设备(即Moster Clarity蓝牙音箱)的语音.

我已经在Android中与该设备配对,我想从设备上的麦克风录制语音(而不是使用手机的内置麦克风).

这是我用于录制的代码:

try {
    isRecording = true;

    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

    if (file == null) {
        File rootDir = Environment.getExternalStorageDirectory();
        file = File.createTempFile(PREFIX, EXTENSION, rootDir);
    }

    recorder.setOutputFile(file.getAbsolutePath());
    recorder.prepare();
    recorder.start();

    timDown = new RecordCountDown(10000, 1000);
    timDown.start();

} catch (Exception e) {
    Log.i("Error Message", "Error Message :" + e.getMessage());
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

android bluetooth

7
推荐指数
1
解决办法
1万
查看次数

Python的join()不会加入我对象的字符串表示(__str__)

我不确定我在这里做错了什么:

>>> class Stringy(object):
...     def __str__(self):
...             return "taco"
...     def __repr__(self):
...             return "taco"
... 
>>> lunch = Stringy()
>>> lunch
taco
>>> str(lunch)
'taco'
>>> '-'.join(('carnitas',lunch))
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
TypeError: sequence item 1: expected string, Stringy found
Run Code Online (Sandbox Code Playgroud)

鉴于我__str__()在Stringy对象中包含了该方法,不应该join()将午餐看作字符串?

python

5
推荐指数
2
解决办法
2073
查看次数

标签 统计

android ×1

bluetooth ×1

python ×1