我正在用听觉反应来播放音频,现在我想在不同的时间戳中播放这首歌。到目前为止,我得到的是:
[testSound,Fs] = audioread('test.wav');
sound(testSound,Fs);是否可以以某种方式指定音轨应从第二声道开始,例如第二声道5?更具体地说,我的音频示例test.wav是45秒长,而不是从一开始就播放声音,我想定义它应该从哪里开始播放。
任何帮助都是非常感谢的!
发布于 2016-10-28 04:11:48
你可以提取出信号的一部分,以便你从5秒开始,然后播放它。简单地说,你会以取样率5倍的速度开始采样,作为起始指标,直到结束,然后播放声音:
[testSound,Fs] = audioread('test.wav'); % From your code
beginSecond = 5; % Define where you want to start playing
beginIndex = floor(beginSecond*Fs); % Find beginning index of where to sample
soundExtract = testSound(beginIndex:end, :); % Extract the signal
sound(soundExtract, Fs); % Play the sound或者,由于您使用的是audioread,您实际上可以指定从哪里开始采样声音。您将使用上述相同的逻辑,并根据示例(示例)指定采样声音的起始和结尾。但是,您首先需要知道采样率是多少,所以您必须调用audioread两次才能获得采样率,最后是信号本身:
beginSecond = 5; % Define where you want to start playing
[~, Fs] = audioread('test.wav'); % Get sampling rate
beginIndex = floor(beginSecond*Fs); % Find beginning index of where to sample
[soundExtract, ~] = audioread('test.wav', [beginIndex inf]); % Extract out the signal from the starting point to the end of the file
sound(soundExtract, Fs); % Play the soundhttps://stackoverflow.com/questions/40295639
复制相似问题