Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

23
LINES

< > BotCompany Repo | #1024610 // audio_findSpeechPartsFromVolumeProfile

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2444L/15K).

// profileSamplingInterval: seconds per profile entry
static L<DoubleRange> audio_findSpeechPartsFromVolumeProfile(float[] profile, double profileSamplingInterval, O... _) {
  optPar double volumeThreshold = 0.15;
  //optPar double minSpeechDuration = 0.2;
  optPar double minSilenceDuration = 0.5;
  optPar double pre = 0.2;
  optPar double post = 0.2;
  
  //int minSpeech = iround(minSpeechDuration/profileSamplingInterval);
  int minSilence = iround(minSilenceDuration/profileSamplingInterval);
  int preTicks = iround(pre/profileSamplingInterval);
  int postTicks = iround(post/profileSamplingInterval);
  
  new BitSet bs;
  for i over profile:
    if (profile[i] >= volumeThreshold)
      bs.set(i);
  
  removeNonStreaksFromBitSetShorterThan(bs, minSilence);
  extendStreaksInBitSet(bs, preTicks, postTicks, l(profile));
  
  ret map(bitSetStreaks(bs), r -> intToDoubleRange(profileSamplingInterval, r));
}

download  show line numbers  debug dex  old transpilations   

Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1024610
Snippet name: audio_findSpeechPartsFromVolumeProfile
Eternal ID of this version: #1024610/7
Text MD5: d50665368a1e3ca69e186d7ceb012462
Transpilation MD5: 87547eb884d4c6223deda325fc4f60d6
Author: stefan
Category: javax / sound
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-21 14:31:34
Source code size: 936 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 161 / 245
Version history: 6 change(s)
Referenced in: [show references]