音声ファイルの無作為抽出について
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kiki
le 16 Sep 2020
Réponse apportée : Atsushi Ohashi
le 17 Sep 2020
音声ファイルの無作為抽出方法を教えてください。
例えば、「001.wav」「002.wav」「003.wav」の音声ファイルがあったとして、
これらからランダムに1つのファイルを選択・再生をするプログラム方法を知りたいです。
0 commentaires
Réponse acceptée
Atsushi Ohashi
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Audio I/O and Waveform Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!