vector<SpeechSegment> CVoiceDetection::FindSpeechSegment( const float* buffer, int sampleRate ) { assert( buffer != NULL); assert( sampleRate != 0 ); //我们通过amdfSize大小的区域来检查人声频率 //我们确保amdfSize内至少含有人声两个周期 int amdfSize = sampleRate / MIN_VOICE_FREQUENCY * 2; for( auto it = m_startEndMap.begin(); it != m_startEndMap.end(); ++it ) { //获取人声区域的中间点,确保这个点是人声 int middleFrameIndex = (it->first + it->second)/2; int middleSampleIndex = middleFrameIndex * m_hop; vector<float> dataForAMDF( buffer+middleSampleIndex, buffer+middleSampleIndex+amdfSize ); //计算平均幅度差 auto amdfResult = AMDFCalc( dataForAMDF ); //计算人声频率 auto voiceFrequence = VoiceFrequenceCalc( amdfResult, sampleRate ); if( 0 != voiceFrequence ) { float beat = float((it->second - it->first)*m_hop)/sampleRate; SpeechSegment smg(voiceFrequence, it->first, it->second, beat); m_speechSegment.push_back( smg ); } } return m_speechSegment; }
void see(t_env *e, int fd, char **arg) { int levelplayer; t_players *player; (void) arg; if ((player = get_player_from_id(e->players, fd)) == NULL) smg(fd, "Player not found ? wtf"); else { levelplayer = player->level; make_see(levelplayer, player, fd, e); } }