Record and save audio with your specific file name for the audio.
11 次查看(过去 30 天)
显示 更早的评论
I want to record and save an audio with my specific filename.wav file and then to test it when it match my voice with that file or not. please help me. this is my code.
clc
clear all
close all
warning off
Fs=8000;%Sampling frequency in hertz
ch=1;%Number of channels--2 options--1 (mono) or 2 (stereo)
datatype='uint8';
nbits=16;%8,16,or 24
Nseconds=5;
% to record audio data from an input device ...
...such as a microphone for processing in MATLAB
recorder=audiorecorder(Fs,nbits,ch);
disp('Start speaking..')
%Record audio to audiorecorder object,...
...hold control until recording completes
recordblocking(recorder,Nseconds);
disp('End of Recording.');
%Store recorded audio signal in numeric array
x=getaudiodata(recorder,datatype);
%Write audio file
audiowrite('test.wav',x,Fs);
回答(1 个)
Walter Roberson
2022-12-4
To allow the user to create the file name use uiputfile
[filename, pathname] = uiputfile('*.wav', 'File name for output');
if isnumeric(filename); return; end %user cancel
fullname = fullfile(pathname, filename);
audiowrite(fullname, x, Fs)
There are a number of posts talking about Voice Recognition; see https://www.mathworks.com/matlabcentral/answers/?term=tag%3A%22voice+recognition%22
Note: some of those posts are actually about Speech Recognition rather than Voice Recognition. Voice Recognition is when you are trying to identify who is speaking. Speech Recognition is when you are trying to identify what they are saying.
1 个评论
Walter Roberson
2022-12-4
Replace
audiowrite('test.wav',x,Fs);
with
[filename, pathname] = uiputfile('*.wav', 'File name for output');
if isnumeric(filename); return; end %user cancel
fullname = fullfile(pathname, filename);
audiowrite(fullname, x, Fs)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Speech Recognition 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!