能够在Android中将录制的语音转换为有趣的音调的选项有哪些? iPhone可能具有http://dirac.dspdimension.com之类的选项,我们是否有一些类似的Android库,可以帮助从录制的文件中创建有趣的声音?要求是在“ talking tom” /“ chipmunkify”的基础上创建一些东西(如果这有助于理解上下文)。
如果没有现成的库,还有什么其他方法可以做到这一点?
一种选择是使用AudioTrack。从API 3开始可用,并且使用非常广泛。它将帮助您修改要失真的音频文件的频率,从而改变音调。较高的音调将为您提供所需的花栗鼠声音。
但是,由于年代久远,AudioTrack可能难以为您实现。尝试使用Android的soundpool API。它灵活,可以一次播放数十种声音,并且可以非常轻松地修改音高/频率。
这是我测试它的方式(它起作用):
SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
boolean isSoundLoaded = false;
float frequencyPitch = 1.3f; // tweak this. it accepts any number between 0.5f and 2.0f
int soundID = soundPool.load(filePath+fileName, 1);
soundPool.setOnLoadCompleteListener(new OnLoadCompleteListener() {
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
isSoundLoaded = true;
if(isSoundLoaded)
{
soundPool.play(soundID, 1f, 1f, 1, 0, frequencyPitch);
}
}
});
[目前,大多数移动电话上的语音调制应用程序似乎都在使用变调调制和一些其他音频效果(请注意,语音变形是要解决的更大的问题)。
在Android上,“ AudioTrack”可帮助您调整音调设置(以及许多其他音频特性),以操纵输入音频,从而获得所需的滑稽/“芯片混响”版本。
尝试将纯数据嵌入应用程序中。纯粹的数据很棒而且学习很有趣。尝试一下,轻松改变声音。
我们可以将FFMPEG用于语音更改。
示例:
/**
* Function to execute FFMPEG Query
*/
private fun exceuteFFMPEG(cmd: Array<String>) {
FFmpeg.execute(cmd)
val rc = FFmpeg.getLastReturnCode()
val output = FFmpeg.getLastCommandOutput()
if (rc == RETURN_CODE_SUCCESS) {
Log.i("GetInfo", "Command execution completed successfully.")
hideProgress()
isEffectAddedOnce = true
start()
} else if (rc == RETURN_CODE_CANCEL) {
Log.i("GetInfo", "Command execution cancelled by user.")
} else {
Log.i(
"GetInfo",
String.format(
"Command execution failed with rc=%d and output=%s.",
rc,
output
)
)
}
}
/**
* Function used to play the audio like a Radio
*/
private fun playRadio(fileName1: String, fileName2: String) {
showProgress()
player?.stop()
val cmd = arrayOf(
"-y",
"-i",
fileName1,
"-af",
"atempo=1",
fileName2
)//Radio
exceuteFFMPEG(cmd)
}
/**
* Function used to play the audio like a Chipmunk
*/
private fun playChipmunk(fileName1: String, fileName2: String) {
showProgress()
player?.stop()
val cmd = arrayOf(
"-y",
"-i",
fileName1,
"-af",
"asetrate=22100,atempo=1/2",
fileName2
)//Chipmunk
exceuteFFMPEG(cmd)
}
/**
* Function used to play the audio like a Robot
*/
private fun playRobot(fileName1: String, fileName2: String) {
showProgress()
player?.stop()
val cmd = arrayOf(
"-y",
"-i",
fileName1,
"-af",
"asetrate=11100,atempo=4/3,atempo=1/2,atempo=3/4",
fileName2
)//Robot
exceuteFFMPEG(cmd)
}
/**
* Function used to play the audio like a Cave
*/
private fun playCave(fileName1: String, fileName2: String) {
showProgress()
player?.stop()
val cmd = arrayOf(
"-y",
"-i",
fileName1,
"-af",
"aecho=0.8:0.9:1000:0.3",
fileName2
)//Cave
exceuteFFMPEG(cmd)
}
[有关更多详细信息,可以在以下位置参考示例
https://github.com/sachinvarma/VoiceChanger
希望,将来可能会对某人有所帮助。