在 Android 手机上录制语音

发布于 2024-10-06 22:26:06 字数 98 浏览 6 评论 0原文

我想在我的 Android 手机上录制语音,但我不知道如何具体操作。我搜索了很多但找不到任何有用的东西。

任何人都可以特别解决这个问题。

谢谢, 大卫

I want to record the Voice on my android mobile and I have no clue how to do that particularly. I have searched a lot but couldn't found anything useful.

Can anyone have a solution to this particularly.

Thanks,
david

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

望喜 2024-10-13 22:26:06

取决于你想要哪种声音 ^^

如果你想做一个备忘录/录音机应用程序,然后继续阅读,

如果你试图录制对话,那么至少目前是不可能的(相信我,我花了 1 个月和我的同事一起搜索这个)。

所以如果你想录制你的声音试试这个:

public class StreamerAudio implements Runnable {

    private static FileOutputStream fOut;
    public static boolean isRecording = false;
    private int buffersize;
    private static AudioRecord arec;

    private int encoding = AudioFormat.ENCODING_PCM_16BIT; 
    private int audioChannel = AudioFormat.CHANNEL_CONFIGURATION_DEFAULT;

    private int audioSource = MediaRecorder.AudioSource.VOICE_DOWNLINK;


    private static MicProject parent = null;

    public StreamerAudio(MicProject parent_){
        this.parent = parent_;
    }

    @Override
    public void run() {
        //openFile();

        buffersize = (int) AudioRecord.getMinBufferSize(11025,audioChannel,AudioFormat.ENCODING_PCM_16BIT);
        arec = new AudioRecord(audioSource,
                11025,
                audioChannel,
                encoding,
                buffersize);
        byte[] buffer = new byte[buffersize];
        byte[] buffer2 = new byte[buffersize];
        byte[] bufferSwap = buffer;

        arec.startRecording();

        isRecording = true;

        while(isRecording) {
            arec.read(buffer, 0, buffersize);
                printBuffer(buffer);
        }  
    }

    public void printBuffer(byte[] buffer) {
        try {
            parent.setBufferToDisplay(buffer);
        } catch (Exception e) {

}

Depends which voice you want ^^

if you want to do a memo/dictaphone application then read on

if your trying to record a conversation, then its not possible at the time being at least (trust me I spend 1 month searching this with my colleagues).

so if you want to record your voice try this:

public class StreamerAudio implements Runnable {

    private static FileOutputStream fOut;
    public static boolean isRecording = false;
    private int buffersize;
    private static AudioRecord arec;

    private int encoding = AudioFormat.ENCODING_PCM_16BIT; 
    private int audioChannel = AudioFormat.CHANNEL_CONFIGURATION_DEFAULT;

    private int audioSource = MediaRecorder.AudioSource.VOICE_DOWNLINK;


    private static MicProject parent = null;

    public StreamerAudio(MicProject parent_){
        this.parent = parent_;
    }

    @Override
    public void run() {
        //openFile();

        buffersize = (int) AudioRecord.getMinBufferSize(11025,audioChannel,AudioFormat.ENCODING_PCM_16BIT);
        arec = new AudioRecord(audioSource,
                11025,
                audioChannel,
                encoding,
                buffersize);
        byte[] buffer = new byte[buffersize];
        byte[] buffer2 = new byte[buffersize];
        byte[] bufferSwap = buffer;

        arec.startRecording();

        isRecording = true;

        while(isRecording) {
            arec.read(buffer, 0, buffersize);
                printBuffer(buffer);
        }  
    }

    public void printBuffer(byte[] buffer) {
        try {
            parent.setBufferToDisplay(buffer);
        } catch (Exception e) {

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文