How to play .wav
65 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nathaniel Sweeney
am 24 Nov. 2017
Kommentiert: Walter Roberson
am 17 Dez. 2018
Is there a way to load and play .wav files? This is what I have:
s = 'diglett.wav';
Fs = 8000;
audiowrite(s,y,Fs);
clear y Fs
[y, Fs] = audioread('diglett.wav');
soundsc(y,Fs);
But I know this is wrong. I really need it to xcorr with recorded audio from mic and I don't know if this is even the right way to do it.
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 24 Nov. 2017
https://www.mathworks.com/help/matlab/ref/audiorecorder.html for recording from mic.
https://www.mathworks.com/help/matlab/ref/audioplayer.html for playing audio.
https://www.mathworks.com/help/matlab/ref/audioread.html for reading a wav
4 Kommentare
NOR AZIEYANI
am 14 Dez. 2018
Okay, my bad.Actually, I am writing a Malay language text to speech program.Its very simple; it reads the string from the .txt file,scan it and then matches it in the database, and plays the wave file that match of the string . The database holds the .wav files of word, e.g. the word "saya" has a corresponding file saya.wav in the database. I know this code is wrong because it cannot play the wav file. Can you help me. So far my code is:
%scan text from file
fid = fopen('saya_1.txt');
C = textscan(fid,'%s %s %f32 %d8 %u %f %f %s %f');
fclose(fid);
%connection to SQLite database
javaaddpath('C:\Users\user\AppData\Roaming\MathWorks\MATLAB\R2013a\sqlite-jdbc-3.8.11.2.jar');
dbpath =('C:\Users\user\Desktop\db\tts.db');
datasource = 'tts';
user = '';
password = '';
driver = 'org.sqlite.JDBC';
protocol = 'jdbc';
subprotocol = 'sqlite';
resource = dbpath;
url = strjoin({protocol, subprotocol, resource}, ':');
conn = database(dbpath, user, password, driver, url);
%match string to database
query = 'SELECT *FROM MALAY';
cursor = exec(conn, query);
cursor = fetch(cursor);
result = cursor.Data;
%match string from scan to database
str = {'C'};
expression = '\w+';
matchStr = regexp(str, expression,'match');
%match the string with voice recording
wavdirectory = 'C:\R2013a\bin\Recordings';
[~, number_of_words] = size(matchStr); %stores number of words in user
% input string
for m = 1:number_of_words
filename = [wavdirectory matchStr{m} '.wav'];
if(exist(filename, 'file') ~= 0)
[y, fs] = audioread(filename);
sound(y, fs);
else
fprintf('Word %s does not exist', wordsstring{m});
end
end
Walter Roberson
am 17 Dez. 2018
filename = fullfile(wavdirectory, [matchStr{m} '.wav']);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!