2014-07-10 1 views
7

나는 인스 트림과 음성 통화의 outstream 변경해야합니다.어떻게 안드로이드에서 주문형 음성 통화를 변경할 수 있습니까? (남자와 여자 등 변경)

예를 들어 남녀의 음성을 바꾸거나 인간의 음성을 만화 음성으로 변경하십시오. 주문형

당신이 어떤 아이디어 나 안드로이드 소스 코드가있는 경우

, 그것은

+0

http://docs.oracle.com/javase/tutorial/sound/MIDI-synth.html \ 추출물이다. 두 번째 방법은 연설에서 텍스트로, 텍스트에서 음성으로 진행됩니다. – Skynet

+0

하지만 실시간으로 음성 사서함에서 변경하고 싶습니다. – MiRHaDi

+0

[This] (http://channel9.msdn.com/coding4fun/articles/Skype-Voice-Changer)가 관심의 대상 일 수 있습니다. – Skynet

답변

1

당신은 참고로 구글 글래스 프로젝트의 사용은 동일 할 수 공유하시기 바랍니다. 여기 here

package com.google.android.glass.sample.waveform; 

import android.app.Activity; 
import android.media.AudioFormat; 
import android.media.AudioRecord; 
import android.media.MediaRecorder.AudioSource; 
import android.os.Bundle; 
import android.widget.TextView; 

/** 
* Receives audio input from the microphone and displays a visualization of that data as a waveform 
* on the screen. 
*/ 
public class WaveformActivity extends Activity { 

    // The sampling rate for the audio recorder. 
    private static final int SAMPLING_RATE = 44100; 

    private WaveformView mWaveformView; 
    private TextView mDecibelView; 

    private RecordingThread mRecordingThread; 
    private int mBufferSize; 
    private short[] mAudioBuffer; 
    private String mDecibelFormat; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.layout_waveform); 

     mWaveformView = (WaveformView) findViewById(R.id.waveform_view); 
     mDecibelView = (TextView) findViewById(R.id.decibel_view); 

     // Compute the minimum required audio buffer size and allocate the buffer. 
     mBufferSize = AudioRecord.getMinBufferSize(SAMPLING_RATE, AudioFormat.CHANNEL_IN_MONO, 
       AudioFormat.ENCODING_PCM_16BIT); 
     mAudioBuffer = new short[mBufferSize/2]; 

     mDecibelFormat = getResources().getString(R.string.decibel_format); 
    } 

    @Override 
    protected void onResume() { 
     super.onResume(); 

     mRecordingThread = new RecordingThread(); 
     mRecordingThread.start(); 
    } 

    @Override 
    protected void onPause() { 
     super.onPause(); 

     if (mRecordingThread != null) { 
      mRecordingThread.stopRunning(); 
      mRecordingThread = null; 
     } 
    } 

    /** 
    * A background thread that receives audio from the microphone and sends it to the waveform 
    * visualizing view. 
    */ 
    private class RecordingThread extends Thread { 

     private boolean mShouldContinue = true; 

     @Override 
     public void run() { 
      android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_AUDIO); 

      AudioRecord record = new AudioRecord(AudioSource.MIC, SAMPLING_RATE, 
        AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, mBufferSize); 
      record.startRecording(); 

      while (shouldContinue()) { 
       record.read(mAudioBuffer, 0, mBufferSize/2); 
       mWaveformView.updateAudioData(mAudioBuffer); 
       updateDecibelLevel(); 
      } 

      record.stop(); 
      record.release(); 
     } 

     /** 
     * Gets a value indicating whether the thread should continue running. 
     * 
     * @return true if the thread should continue running or false if it should stop 
     */ 
     private synchronized boolean shouldContinue() { 
      return mShouldContinue; 
     } 

     /** Notifies the thread that it should stop running at the next opportunity. */ 
     public synchronized void stopRunning() { 
      mShouldContinue = false; 
     } 

     /** 
     * Computes the decibel level of the current sound buffer and updates the appropriate text 
     * view. 
     */ 
     private void updateDecibelLevel() { 
      // Compute the root-mean-squared of the sound buffer and then apply the formula for 
      // computing the decibel level, 20 * log_10(rms). This is an uncalibrated calculation 
      // that assumes no noise in the samples; with 16-bit recording, it can range from 
      // -90 dB to 0 dB. 
      double sum = 0; 

      for (short rawSample : mAudioBuffer) { 
       double sample = rawSample/32768.0; 
       sum += sample * sample; 
      } 

      double rms = Math.sqrt(sum/mAudioBuffer.length); 
      final double db = 20 * Math.log10(rms); 

      // Update the text view on the main thread. 
      mDecibelView.post(new Runnable() { 
       @Override 
       public void run() { 
        mDecibelView.setText(String.format(mDecibelFormat, db)); 
       } 
      }); 
     } 
    } 
} 
관련 문제