当前位置:网站首页>matlab 实现语音信号重采样和归一化,并播放比对效果
matlab 实现语音信号重采样和归一化,并播放比对效果
2022-07-02 01:25:00 【胡刚2016】
在前几节的基础上,进行此节的实验。
推荐阅读:
matlab 使用 audiorecorder、recordblocking录制声音,play 播放声音,audiowrite 保存声音
matlab 使用 audioread 、 sound 读取和播放 wav 文件
matlab 使用 resample 完成重采样
注意:
本次所使用的 wav 文件的时长为5秒,所以我的代码有几行写了 pause(6); 目的是为了使得播放完声音还能有1秒的空余,再来播放下一段声音。
我使用的是matlab2018a,所以在这个版本中 wavread 函数已经被废弃了 ,我只能使用 audioread 函数。
如果你没有wav语音文件,你可以参照推荐阅读的第一篇博客自己制作一个,非常的方便。
%语音信号采样频率变换实验
clc
clear all
%[x,fs1]=wavread('C2_2_y.wav');% wavread 函数已经被废弃了
[x,fs1]=audioread('C2_2_y.wav');%matlab2018a,可以使用 audioread 这个函数
s1=1:length(x);
t1=s1/fs1;
xmax=max(abs(x));%获得所有sample的最大值的绝对值
x=x/xmax;%将wav文件的每一个sample值除以最大的sample值,使得所有的x都在[-1,1]区间内,完成归一化
figure(1)
subplot(311)
plot(t1,x);
xlabel('时间/s');
ylabel('归一化幅值');
title('(a)原始信号');
sound(x,fs1);
pause(6);%因为播放的语音时间为5秒,所以这里间隔6秒,以便下次播放,不然三个声音播放就重叠在一起了
%2倍重采样
p=2;q=1;
x1=resample(x,p,q);%重采样信号,使得信号的元素数量扩大两倍
x1max=max(abs(x1));
x1=x1/x1max;%归一化
fa=fs1*p/q;%重采样后信号的频率,也就是 原信号的频率 * 重采样的倍数
ta=(1:length(x1))/fa;%重采样后每个信号的时间坐标
subplot(312);
plot(ta,x1);
sound(x1,fa);
pause(6);%因为播放的语音时间为5秒,所以这里间隔6秒,以便下次播放,不然三个声音播放就重叠在一起了
xlabel('时间/s');
ylabel('归一化幅值');
title('(b)2倍采样率');
%0.5倍重采样
p=1;q=2;
x2=resample(x,p,q);
x2max=max(abs(x2));
x2=x2/x2max;
fb=fs1*p/q;
tb=(1:length(x2))/fb;
subplot(313);
plot(tb,x2);
xlabel('时间/s');
ylabel('归一化幅值');
title('(c)1/2采样率');
sound(x2,fb);

边栏推荐
- 关于ASP.NET CORE使用DateTime日期类型参数的一个小细节
- [IVX junior engineer training course 10 papers to get certificates] 0708 news page production
- Global and Chinese market of wireless charging magnetic discs 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese markets for maritime services 2022-2028: Research Report on technology, participants, trends, market size and share
- The pain of Xiao Sha
- Recommend an online interface mock tool usemock
- Basic concepts of machine learning
- Global and Chinese markets for freight and logistics 2022-2028: Research Report on technology, participants, trends, market size and share
- Cat Party (Easy Edition)
- No converter found for return value of type: class
猜你喜欢

基于SSM实现微博系统

How does schedulerx help users solve the problem of distributed task scheduling?

Self drawing of menu items and CListBox items

How does schedulerx help users solve the problem of distributed task scheduling?

关于ASP.NET CORE使用DateTime日期类型参数的一个小细节

ACM教程 - 快速排序(常规 + 尾递归 + 随机基准数)

GL Studio 5 installation and experience

Datawhale community blackboard newspaper (issue 1)

Sql--- related transactions

Unity AssetBundle subcontracting
随机推荐
Part 29 supplement (XXIX) basis of ECMAScript
GL Studio 5 安装与体验
969 interlaced string
NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
卷積神經網絡(包含代碼與相應圖解)
Based on Simulink and FlightGear, the dynamic control of multi rotor UAV in equilibrium is modeled and simulated
浅浅了解Servlet
Global and Chinese markets of digital crosspoint switches and mux/demux 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets of beverage seasoning systems 2022-2028: Research Report on technology, participants, trends, market size and share
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
[IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
[IVX junior engineer training course 10 papers to get certificates] 01 learn about IVX and complete the New Year greeting card
The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
Basic number theory -- Gauss elimination
Self drawing of menu items and CListBox items
The first "mobile cloud Cup" empty publicity meeting, looking forward to working with developers to create a new world of computing!
Luogu p1775 stone merger (weakened version)
Design and implementation of radio energy transmission system
基于SSM实现微博系统
Comprehensive broadcast of global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share