【问题标题】:Is there a service which provides audio recording within an app?是否有在应用程序内提供录音的服务?
【发布时间】:2021-09-03 17:28:31
【问题描述】:

我正在开发一个应用程序,该应用程序将利用手机的麦克风来记录和存储音频。但是,质量很糟糕。

有几个录音应用程序使用相同的麦克风,但它们的质量非常出色。

是否有任何服务可以让我实现这一目标?我记得 Twilio 以前提供过类似的东西,但它似乎已经停止了。基本上,用户将能够录制音频剪辑,然后将它们存储起来供以后播放。如果一项服务可以做到其中一个或两个,那就完美了。

你知道有这样的服务吗?

【问题讨论】:

    标签: android ios audio-recording


    【解决方案1】:

    您可以通过这种方式启动 MediaRecorder。这里的关键是setAudioEncodingBitRatesetAudioSamplingRate

    MediaRecorder recorder = new MediaRecorder();
                            recorder.setAudioEncodingBitRate(384000);
                            recorder.setAudioSamplingRate(48000);
                            recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
                            recorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
                            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
                            recorder.setOutputFile(outputFile); // path of your recording in phone storage
                            try {
                                recorder.prepare();
                                recorder.start();
                                
                            } catch (IOException e) {
                                Log.d(TAG, "onCreate: " + e);
                            }
    

    您可以通过这种方式停止媒体录制:

        private void stopRecording() {
    
                File file = new File(outputFile); // this is result of recording, you can play this file via MediaPlayer
     try {
                if (recorder != null) {
                    recorder.stop();
                    recorder.release();
                    recorder = null;
                }
            } catch (Exception e) {
                Log.d(TAG, "stopMediaRecording: ");
            }        }
    

    【讨论】:

      猜你喜欢
      • 2012-08-13
      • 2012-04-01
      • 1970-01-01
      • 2014-08-17
      • 2016-12-23
      相关资源
      最近更新 更多