import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; // We're aiming for: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz // as per http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4 static void convertWAVForSphinx(File inputFile, File outputFile) ctex { AudioFormat outputFormat = sphinxAudioFormat(); AudioFileFormat inputFileFormat = AudioSystem.getAudioFileFormat(inputFile); AudioFormat inputFormat = inputFileFormat.getFormat(); AudioInputStream sourceStream = AudioSystem.getAudioInputStream(inputFile); AudioInputStream stream = AudioSystem.getAudioInputStream(outputFormat, sourceStream); int nWrittenBytes = AudioSystem.write(stream, AudioFileFormat.Type.WAVE, outputFile); sourceStream.close(); stream.close(); }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1004799 |
Snippet name: | convertWAVForSphinx |
Eternal ID of this version: | #1004799/2 |
Text MD5: | 183d16eb35251cdc50af16979d64996d |
Author: | stefan |
Category: | javax / speech |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-02-26 00:04:33 |
Source code size: | 968 bytes / 20 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 631 / 635 |
Version history: | 1 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1007036 - pcmToWAVE |