在Java中开始录制操作时,如何检测静音?什么是PCM数据?如何在Java中计算PCM数据?
我找到了解决方案:
package bemukan.voiceRecognition.speechToText;
import javax.sound.sampled.*;
import java.io.*;
public class RecordAudio {
private File audioFile;
protected boolean running;
private ByteArrayOutputStream out;
private AudioInputStream inputStream;
final static float MAX_8_BITS_SIGNED = Byte.MAX_VALUE;
final static float MAX_8_BITS_UNSIGNED = 0xff;
final static float MAX_16_BITS_SIGNED = Short.MAX_VALUE;
final static float MAX_16_BITS_UNSIGNED = 0xffff;
private AudioFormat format;
private float level;
private int frameSize;
public RecordAudio(){
getFormat();
}
private AudioFormat getFormat() {
File file = new File("src/Facebook/1.wav");
AudioInputStream stream;
try {
stream = AudioSystem.getAudioInputStream(file);
format=stream.getFormat();
frameSize=stream.getFormat().getFrameSize();
return …Run Code Online (Sandbox Code Playgroud) 我想将超类对象getter复制到子类对象setter.但是我怎么能这么做呢.我正在寻找像克隆这样的东西.你能请我帮我找到吗?
非常感谢你.
一个简单的代码:
超级课程:
public class SuperClass1{
private String name;
private String surname;
public void setName(String name){
this.name=name;
}
public String getName(){
return this.name;
}
public void setSurname(String surname){
this.surname=surname;
}
public String getSurname(){
return this.surname;
}
}
Run Code Online (Sandbox Code Playgroud)
子类
public class SubClass1 extends SuperClass1{
private float gpa;
public void setGpa(float gpa){
this.gpa=gpa;
}
public float getGpa(){
return gpa;
}
}
Run Code Online (Sandbox Code Playgroud)
和来电班:
public class CallerClass1{
public static void main(String[] args){
SuperClass1 super1=new SuperClass1();
SubClass1 subclass1=new SubClass1();
//How to subclass1 object values …Run Code Online (Sandbox Code Playgroud) 我想知道Hibernate如何找到NullValidator扩展ConstraintValidator接口的类,即使@Null注释定义如下:
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = { })
public @interface Null {}
Run Code Online (Sandbox Code Playgroud) 我有个问题.我想阻止用户在没有登录jsf2的情况下访问页面.当用户直接将受限制的页面URL写入浏览器时,他/她不应该看到该页面.就像上面的情况一样,他/她必须被重定向到登录页面.我该如何以编程方式执行此操作?
我想在PDF中插入一段包含粗体和非粗体区域的文本,但我不知道如何才能这样做?
我正在使用iText5(java).
这是我的代码:
public class CreatePdf{
private Font bigFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 12, Font.BOLD, new Color(0, 0, 0));
private Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 8, Font.NORMAL, new Color(0, 0, 0));
public void create(){
Paragraph parag1=new Paragraph("Number: ",bigFont);//This gonna be bold font
Paragraph parag2=new Paragraph("12", smallFont); //This gonna be normal font
//Create one paragraph from these two paragraphs. But How ?
}
}
Run Code Online (Sandbox Code Playgroud) 在我的项目中,我使用 mvc 模式。我不知道数据库操作是哪个类进行的。那是我正在 Model 类中进行数据库操作,但我不知道这是正确的。我很困惑。控制器类也许可以正确的进行插入、删除、更新操作。但是,我不知道到底要在哪里进行数据库操作。我也想在数据库中搜索一个值。模型类方便这些操作吗?谢谢,
嗨,我想将一个类的所有String字段值转换为它们的大写格式。我怎样才能做到这一点?请帮忙。
例子:
public class ConvertStringToUppercase{
private String field1; //to be converted Uppercase
private String field2; //to be converted Uppercase
private String field3; //to be converted Uppercase
...... //more fields
}
Run Code Online (Sandbox Code Playgroud)