Record and save audio with your specific file name for the audio.

5 views (last 30 days)
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);
  3 Comments
kim
kim on 4 Dec 2022
Edited: kim on 4 Dec 2022
yes please help me . I want to create a real time audio and name it by myself I dont want the test.wav to be a named. like when youre entering a voice activation your voice will verify it according to the audio. and then it will say access granted or denied sorry for my bad english. @Walter Roberson
kim
kim on 4 Dec 2022
Iam creating a voice recognition that will allow user to register and save his/her audio to the database and when he/she log in or speak it will detect that its from his/her and it will access granted. what should I write with that instead?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 4 Dec 2022
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 Comment
Walter Roberson
Walter Roberson on 4 Dec 2022
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)

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!