如何在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)
我怎样才能做到这一点?
我不确定我在这里做错了什么:
>>> 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()将午餐看作字符串?