我有一个应用程序,它记录来自用户麦克风的语音样本,然后将其上传到服务器,然后服务器对其进行处理.看来我必须用以下参数记录以避免IllegalArgumentException:
Encoding encoding = AudioFormat.Encoding.PCM_SIGNED;
float sampleRate = 44100.0F;
int sampleSizeInBits = 16;
int channels = 2;
int frameSize = 4;
float frameRate = 44100.0F;
boolean bigEndian = false;
Run Code Online (Sandbox Code Playgroud)
但是我需要将它记录在16khz,而不是44.1,(sampleRate和framerate都是,我假设)并且它必须是单声道(1声道).PCM签名也是强制性的,所以这很好.(服务器非常挑剔,我无法对其进行任何更改.)如何使用Java转换它?
我通过HttpClient将音频文件作为Filebody提交给servlet,将其保存在服务器上,然后进行处理.
我是Swing的新手,首先.我试图设置录音小程序的背景颜色,使其与我的网页混合(白色而不是默认的灰色),但似乎永远不会改变.继承人applet初始化......
public void init()
{
setLayout(null);
setBackground(Color.white);
JLabel recorder = new JLabel("Record");
JLabel fileName = new JLabel("Please Enter File Name");
JLabel status = new JLabel("Status...");
fnametxt = new JTextField("FileNameHere");
statustxt = new JTextField("");
record = new JButton("Record");
play = new JButton("Play");
pause = new JButton("Pause");
stop = new JButton("Stop");
send = new JButton("Upload");
listen = new JButton("Listen");
save = new JButton("Save and Submit");
//A bunch of other stuff, event listeners and whatnot.
Run Code Online (Sandbox Code Playgroud)
我没有使用布局管理器,我手动设置所有位置.有任何想法吗?