1 | import javax.sound.sampled.AudioFileFormat; |
2 | import javax.sound.sampled.AudioFormat; |
3 | import javax.sound.sampled.AudioInputStream; |
4 | import javax.sound.sampled.AudioSystem; |
5 | import javax.sound.sampled.UnsupportedAudioFileException; |
6 | |
7 | // We're aiming for: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz |
8 | // as per http://cmusphinx.sourceforge.net/wiki/tutorialsphinx4 |
9 | |
10 | static void convertWAVForSphinx(File inputFile, File outputFile) ctex { |
11 | AudioFormat outputFormat = sphinxAudioFormat(); |
12 | |
13 | AudioFileFormat inputFileFormat = AudioSystem.getAudioFileFormat(inputFile); |
14 | AudioFormat inputFormat = inputFileFormat.getFormat(); |
15 | AudioInputStream sourceStream = AudioSystem.getAudioInputStream(inputFile); |
16 | AudioInputStream stream = AudioSystem.getAudioInputStream(outputFormat, sourceStream); |
17 | int nWrittenBytes = AudioSystem.write(stream, AudioFileFormat.Type.WAVE, outputFile); |
18 | sourceStream.close(); |
19 | stream.close(); |
20 | } |
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: | 632 / 636 |
Version history: | 1 change(s) |
Referenced in: | [show references] |