⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdata.java

📁 这是一个从音频信号里提取特征参量的程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
	}	// tags	//	String level_size_tag = CData.IO_CDATA_LEVEL_SIZE;		// values	//	String level_size = io_d.getProperty(level_size_tag);	System.out.println(level_size);	int l_size = Integer.valueOf(level_size).intValue();		search_levels_d.clear();	// store all levels	//	for (int i= 0; i < l_size; i++) {	    String prefix = CData.IO_SEARCHLEVEL_PREFIX + String.valueOf(i);	    SearchLevel curr_level = new SearchLevel();	    curr_level.load(prefix);	    System.out.println(prefix);	    addLevel(i, curr_level);	}	// update UI	//	main_frame_d.updateAll();    }    /**     * load the data from a file     *      * @param none     * @return void     */    public static void convertModels( String input_file_a, 				      String input_format_a,				      String output_file_a, 				      String output_sm_file_a, 				      String out_format_a,				      String out_type_a){	// get the current runtime environment	//	Runtime environ = Runtime.getRuntime();	// make sure we got a valid runtime environment	//	if (environ == null) {	    System.out.println("Didn't get Runtime for script" );	    return;	}	//output_sm_file_a = "/home/huang/temp/sm.sof";	String[] cmdarray = new String[10];	// launch the script with the start option	//	Process start_proc = (Process)null;	try {	    cmdarray[0] = ISIP_NETWORK_CONVERTER;	    cmdarray[1] = input_file_a;	    cmdarray[2] = output_file_a;	    cmdarray[3] = output_sm_file_a;	    cmdarray[4] = "-input_format";	    cmdarray[5] = input_format_a;	    cmdarray[6] = "-output_format";	    cmdarray[7] = out_format_a;	    cmdarray[8] = "-output_type";	    cmdarray[9] = out_type_a;	    String command = new String(" " +cmdarray[0]			       + " " + cmdarray[1] +  " " +cmdarray[2]			       + " " + cmdarray[3] +  " " +cmdarray[4]			       + " " + cmdarray[5] +  " " +cmdarray[6]			       + " " + cmdarray[7] +  " " +cmdarray[8]			       + " " + cmdarray[9] );	    start_proc = environ.exec(cmdarray);	} catch (java.io.IOException e) {	    System.out.println("cannot start the isip_network_converter");	    e.printStackTrace(System.out);	    return;	}	// make sure we got a valid process	//	if (start_proc == null) {	    System.out.println(" Listen start_proc came back null");	    return;	}		try{	    System.out.println(" " +cmdarray[0]			       + " " + cmdarray[1] +  " " +cmdarray[2]			       + " " + cmdarray[3] +  " " +cmdarray[4]			       + " " + cmdarray[5] +  " " +cmdarray[6]			       + " " + cmdarray[7] +  " " +cmdarray[8]			       + " " + cmdarray[9] );	    start_proc.waitFor();	}	catch(java.lang.InterruptedException e){	    System.out.println(" start_proc wait for fail");	    return;	}    }    /**     * removeTempFile     *      * @param none     * @return void     */    public static void removeTempFile() {	// remove the temporary file	//	try {	    if ( temp_file_d != null  ){		File tmp = new File(temp_file_d);		if ( tmp.exists() ){		    tmp.delete();		}		temp_file_d = null;	    }	} catch ( Exception e ) {	    e.printStackTrace();	}    }    /**     * load the data from a file     *      * @param none     * @return void     */    public static String chooseFile(String approve_string_a) {	String curr_dir = System.getProperty("user.dir");	String file_name = new String();		// set the file chooser	//	JFileChooser fc = new JFileChooser(curr_dir);	fc.setAcceptAllFileFilterUsed(false);	//fc.setDialogType(type_a);	UIFileFilter sof_filter = new UIFileFilter();	sof_filter.addExtension(FILE_FILTER_EXTENSION_DIGRAPH);	sof_filter.setDescription(FILE_FILTER_DESCRIPTION_DIGRAPH);	fc.addChoosableFileFilter(sof_filter);	UIFileFilter jsgf_filter = new UIFileFilter();	jsgf_filter.addExtension(FILE_FILTER_EXTENSION_JSGF);	jsgf_filter.setDescription(FILE_FILTER_DESCRIPTION_JSGF);	fc.addChoosableFileFilter(jsgf_filter);			      	UIFileFilter bin_filter = new UIFileFilter();	bin_filter.addExtension(FILE_FILTER_EXTENSION_BINARY);	bin_filter.setDescription(FILE_FILTER_DESCRIPTION_BINARY);	fc.addChoosableFileFilter(bin_filter);	UIFileFilter inb_filter = new UIFileFilter();	inb_filter.addExtension(FILE_FILTER_EXTENSION_NATIVE);	inb_filter.setDescription( FILE_FILTER_DESCRIPTION_NATIVE );	fc.addChoosableFileFilter(inb_filter);	int ret = fc.showDialog(main_frame_d, approve_string_a);	String description = fc.getFileFilter().getDescription();	if ( ret == JFileChooser.APPROVE_OPTION ){	    if ( description.equals(FILE_FILTER_DESCRIPTION_DIGRAPH) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_DIGRAPH)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_DIGRAPH;	    }	    else if ( description.equals(FILE_FILTER_DESCRIPTION_JSGF) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_JSGF)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_JSGF;	    }	    else if ( description.equals(FILE_FILTER_DESCRIPTION_NATIVE) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_NATIVE)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_NATIVE;	    }	    else if ( description.equals(FILE_FILTER_DESCRIPTION_BINARY) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_BINARY)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_BINARY;	    }	    else {		file_name = fc.getSelectedFile().getAbsolutePath();	    }	}	else{	    file_name = null;	}		// exist	//	return file_name;    }    /**     * load the data from a file     *      * @param none     * @return void     */    public static String chooseAnyFile(String approve_string_a) {	String curr_dir = System.getProperty("user.dir");	String file_name = new String();		// set the file chooser	//	JFileChooser fc = new JFileChooser(curr_dir);	fc.setAcceptAllFileFilterUsed(true);	//fc.setDialogType(type_a);	int ret = fc.showDialog(main_frame_d, approve_string_a);	String description = fc.getFileFilter().getDescription();	if ( ret == JFileChooser.APPROVE_OPTION ){	    file_name = fc.getSelectedFile().getAbsolutePath();	}	else{	    file_name = null;	}		// exist	//	return file_name;    }    /**     * load the data from a file     *      * @param none     * @return void     */    public static String chooseLMFile(String curr_dir_a) {	String curr_dir = curr_dir_a;	if ( curr_dir_a == null ){	    curr_dir = System.getProperty("user.dir");	}	String file_name = new String();		// set the file chooser	//	JFileChooser fc = new JFileChooser(curr_dir);	fc.setAcceptAllFileFilterUsed(false);	//fc.setDialogType(type_a);	UIFileFilter sof_filter = new UIFileFilter();	sof_filter.addExtension(FILE_FILTER_EXTENSION_DIGRAPH);	sof_filter.setDescription(FILE_FILTER_DESCRIPTION_DIGRAPH);	fc.addChoosableFileFilter(sof_filter);	UIFileFilter jsgf_filter = new UIFileFilter();	jsgf_filter.addExtension(FILE_FILTER_EXTENSION_JSGF);	jsgf_filter.setDescription(FILE_FILTER_DESCRIPTION_JSGF);	fc.addChoosableFileFilter(jsgf_filter);	UIFileFilter binary_filter = new UIFileFilter();	binary_filter.addExtension(FILE_FILTER_EXTENSION_BINARY);	binary_filter.setDescription(FILE_FILTER_DESCRIPTION_BINARY);	fc.addChoosableFileFilter(binary_filter);			      	UIFileFilter inb_filter = new UIFileFilter();	inb_filter.addExtension(FILE_FILTER_EXTENSION_NATIVE);	inb_filter.setDescription( FILE_FILTER_DESCRIPTION_NATIVE );	fc.addChoosableFileFilter(inb_filter);			      	int ret = fc.showDialog(main_frame_d, "OK");	String description = fc.getFileFilter().getDescription();	open_lm_file_description_d = description;	if ( ret == JFileChooser.APPROVE_OPTION ){	    if ( description.equals(FILE_FILTER_DESCRIPTION_DIGRAPH) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_DIGRAPH)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_DIGRAPH;	    }	    else if ( description.equals(FILE_FILTER_DESCRIPTION_JSGF) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_JSGF)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_JSGF;	    }	    else if ( description.equals(FILE_FILTER_DESCRIPTION_BINARY) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_BINARY)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_BINARY;	    }	    else if ( description.equals(FILE_FILTER_DESCRIPTION_NATIVE) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_NATIVE)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_NATIVE;	    }	    else {		file_name = fc.getSelectedFile().getAbsolutePath();	    }	}	else{	    file_name = null;	}		// exist	//	return file_name;    }    /**     * load the data from a file     *      * @param none     * @return void     */    public static String chooseSMFile(String curr_dir_a) {	String curr_dir = curr_dir_a;	if ( curr_dir_a == null ){	    curr_dir = System.getProperty("user.dir");	}	String file_name = new String();		// set the file chooser	//	JFileChooser fc = new JFileChooser(curr_dir);	fc.setAcceptAllFileFilterUsed(false);	//fc.setDialogType(type_a);	UIFileFilter sof_filter = new UIFileFilter();	sof_filter.addExtension(FILE_FILTER_EXTENSION_SM);	sof_filter.setDescription(FILE_FILTER_DESCRIPTION_SM);	fc.addChoosableFileFilter(sof_filter);	int ret = fc.showDialog(main_frame_d, "OK");	String description = fc.getFileFilter().getDescription();	if ( ret == JFileChooser.APPROVE_OPTION ){	    if ( description.equals(FILE_FILTER_DESCRIPTION_SM) &&		 (!UIFileFilter.getExtension(fc.getSelectedFile())		  .equals(FILE_FILTER_EXTENSION_SM)) ){		file_name = fc.getSelectedFile().getAbsolutePath() +		    "." + FILE_FILTER_EXTENSION_SM;	    }	    else {		file_name = fc.getSelectedFile().getAbsolutePath();	    }	}	else{	    file_name = null;	}		// exist	//	return file_name;    }    /**     * store the data to a file     *      * @param none     * @return void     */    public static void storeSymbols(Vector symbols_a, String size_prefix_a,				     String symbol_prefix_a) {	// get the io to set properties	//	Properties io = CData.io_d;		// store all data members	//	String symbol_size = String.valueOf(symbols_a.size());	io.setProperty(size_prefix_a, symbol_size);	// store all symbols	//	for (int i= 0; i < symbols_a.size(); i++) {	    String curr_symbol = (String)symbols_a.get(i);	    String prefix = symbol_prefix_a + String.valueOf(i);	    io.setProperty(prefix, curr_symbol);	}    }    /**     * load the data from a file     *      * @param none     * @return void     */    public static void loadSymbols(Vector symbols_a, String size_prefix_a,				     String symbol_prefix_a) {	// get the io to set properties	//	Properties io = CData.io_d;		// load all data members	//	String symbol_size = io.getProperty(size_prefix_a);	int s_size = 0;	if ( symbol_size != null ){	    s_size = Integer.valueOf(symbol_size).intValue();	}		//System.out.println(symbol_size);	// load all symbols	//	for (int i= 0; i < s_size; i++) {	    String key = symbol_prefix_a + String.valueOf(i);	    String curr_symbol = io.getProperty(key);	    symbols_a.add(curr_symbol);	    //System.out.println(key + " " + curr_symbol);	}    }    /**     * sortSymbols     *      * @param the list of symbols to be sorted     * @return void     * the repeated elements will not be occured in the new list     */    public static boolean sortSymbols(Vector symbols_a) {	Object[] symbols = symbols_a.toArray();	Arrays.sort(symbols);	symbols_a.clear();	for ( int i = 0; i < symbols.length; i++ ){	    String last;	    if ( symbols_a.size() > 0 ){		last = (String)symbols_a.lastElement();		if (!last.equals((String)symbols[i])) {		    symbols_a.add((String)symbols[i]);		}	    }	    else {		symbols_a.add((String)symbols[i]);	    }	}	return true;    }    /**     * conver a string vector to a index vector     *      * @param x1: (input) x-coordinate of the first point     * @param y1: (input) y-coordinate of the first point     * @param x2: (input) x-coordinate of the second point     * @param y2: (input) x-coordinate of the second point     * @return a vector of string     */    static public double distance(int x1, int y1, int x2, int y2) {        double distance = 0.0;        // claculate the euclidean distance        //        double deltaX = x2 - x1;        double deltaY = y2 - y1;        double sqrX = deltaX * deltaX;        double sqrY = deltaY * deltaY;        distance = Math.sqrt((double)sqrX + (double)sqrY);        // return the distance        //        return distance;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -