音声ファイルの無作為抽出について
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kiki
am 16 Sep. 2020
Beantwortet: Atsushi Ohashi
am 17 Sep. 2020
音声ファイルの無作為抽出方法を教えてください。
例えば、「001.wav」「002.wav」「003.wav」の音声ファイルがあったとして、
これらからランダムに1つのファイルを選択・再生をするプログラム方法を知りたいです。
0 Kommentare
Akzeptierte Antwort
Atsushi Ohashi
am 17 Sep. 2020
音声ファイル名を1つのセル配列にまとめ、randi 関数を使ってインデックスを求める方法がございます。
% ファイルをセル配列に格納
cellFiles = {'001.wav', '002.wav', '003.wav'};
% ランダムなインデックス値を取得
idx = randi( numel(cellFiles), 1 );
% インデックス値からファイル名を取得
filename = cellFiles{idx};
% 音声再生
[y, Fs] = audioread( filename);
sound(y, Fs);
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio I/O and Waveform Generation 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!