• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java FLACFileWriter类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中net.sourceforge.javaflacencoder.FLACFileWriter的典型用法代码示例。如果您正苦于以下问题:Java FLACFileWriter类的具体用法?Java FLACFileWriter怎么用?Java FLACFileWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

FLACFileWriter类属于net.sourceforge.javaflacencoder包,在下文中一共展示了FLACFileWriter类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: saveOutputStreamArray

点赞 3

import net.sourceforge.javaflacencoder.FLACFileWriter; //导入依赖的package包/类
public void saveOutputStreamArray(ByteArrayOutputStream out) {
    byte audioBytes[] = out.toByteArray();
    int frameSizeInBytes = format.getFrameSize();
    ByteArrayInputStream bais = new ByteArrayInputStream(audioBytes);
    AudioInputStream  audioInputStream = new AudioInputStream(bais, format, audioBytes.length / frameSizeInBytes);

    long milliseconds = (long) ((audioInputStream.getFrameLength() * 1000) / format.getFrameRate());
    double duration = milliseconds / 1000.0;

    try {

        AudioSystem.write(audioInputStream, FLACFileWriter.FLAC, speechFile);
        //  AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, speechFile);
    } catch (Exception ex) {
        ex.printStackTrace();
    }

}
 

开发者ID:tsoglani,
项目名称:SpeechRaspberrySmartHouse,
代码行数:19,
代码来源:Jarvis.java

示例2: run

点赞 3

import net.sourceforge.javaflacencoder.FLACFileWriter; //导入依赖的package包/类
public void run() {
        //        System.out.println("getTimeIn:" + getTimeIn("Greece"));

        //        playAudio();
        //        findMobile();

        // boolean isCommandExcecuted = processRespond("kitchen lights off");
        //  System.out.println("command excecuted " + isCommandExcecuted);
try{
         mic = new Microphone(FLACFileWriter.FLAC);
        //  AudioFromat format=javax.sound.sampled.AudioFormat.Encoding.PCM_SIGNED;
        //mic = new Microphone(javax.sound.sampled.AudioFileFormat.Type.WAVE);
  
        }catch(Exception e){} 
        activate();
    }
 

开发者ID:tsoglani,
项目名称:SpeechRaspberrySmartHouse,
代码行数:17,
代码来源:Jarvis.java

示例3: openHttpsPostConnection

点赞 2

import net.sourceforge.javaflacencoder.FLACFileWriter; //导入依赖的package包/类
/**
 * Opens a HTTPSPostConnection that posts data from a TargetDataLine input
 * @param murl The URL you want to post to.
 * @param mtl The TargetDataLine you want to post data from. <b>Note should be open</b>
 */
private void openHttpsPostConnection(String murl, TargetDataLine mtl, int sampleRate) {
	URL url;
	try {
		url = new URL(murl);
		HttpsURLConnection httpConn = getHttpsURLConnection(sampleRate, url);
		// this opens a connection, then sends POST & headers.
		final OutputStream out = httpConn.getOutputStream();
		//Note : if the audio is more than 15 seconds
		// dont write it to UrlConnInputStream all in one block as this sample does.
		// Rather, segment the byteArray and on intermittently, sleeping thread
		// supply bytes to the urlConn Stream at a rate that approaches
		// the bitrate ( =30K per sec. in this instance ).
		System.out.println("Starting to write data to output...");
		final AudioInputStream ais = new AudioInputStream(mtl);;
		AudioSystem.write(ais, FLACFileWriter.FLAC, out);
		//Output Stream is automatically closed
		// do you need the trailer?
		// NOW you can look at the status.

		//Diagonostic Code.
		/*int resCode = httpConn.getResponseCode();
		if (resCode / 100 != 2) {
			System.out.println("ERROR");
		}
		Scanner scanner = new Scanner(httpConn.getInputStream());
		while(scanner.hasNextLine()){
			System.out.println("UPSTREAM READS:" + scanner.nextLine());
		}
		scanner.close();*/
		System.out.println("Upstream Closed...");
	}catch(IOException ex){
		ex.printStackTrace();
	}
}
 

开发者ID:OpenASR,
项目名称:idear,
代码行数:40,
代码来源:GSpeechDuplex.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)