当前位置:网站首页>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);

边栏推荐
- [dynamic planning] interval dp:p3205 Chorus
- Circular statements in shell programming
- GL Studio 5 安装与体验
- Global and Chinese markets for food allergens and intolerance tests 2022-2028: Research Report on technology, participants, trends, market size and share
- About asp Net core uses a small detail of datetime date type parameter
- [IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production
- 只是以消费互联网的方式和方法来落地和实践产业互联网,并不能够带来长久的发展
- Convolutional neural network (including code and corresponding diagram)
- Ubuntu20.04 PostgreSQL 14 installation configuration record
- The technology boss is ready, and the topic of position C is up to you
猜你喜欢

GL Studio 5 installation and experience

学习笔记25--多传感器前融合技术

How can I batch produce the same title for the video?
![[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility](/img/8b/e51867cfe9d200ac385e1d1f01e4b3.jpg)
[Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility

Learn C language from scratch day 025 (maze)

It's already 30. Can you learn programming from scratch?

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

Memorabilia of domestic database in June 2022

Single chip microcomputer -- hlk-w801 transplant NES simulator (III)

【图像增强】基于Frangi滤波器实现血管图像增强附matlab代码
随机推荐
Global and Chinese market of avionics systems 2022-2028: Research Report on technology, participants, trends, market size and share
Basic usage of shell script
Leetcode 45 Jumping game II (2022.02.14)
Brief introduction to the development of mobile network
What are the affordable Bluetooth headsets? Student party parity Bluetooth headset recommendation
Recommend an online interface mock tool usemock
6-2漏洞利用-ftp不可避免的问题
Global and Chinese market of wireless chipsets 2022-2028: Research Report on technology, participants, trends, market size and share
We should make clear the branch prediction
What is commercial endowment insurance? Is commercial endowment insurance safe?
8.8.4-PointersOnC-20220215
Docker installing Oracle_ 11g
Basic usage of three JS high-order functions --filter---map---reduce
I'll teach you to visit Amazon RDS for a year and build a MySQL cloud database (only 10 minutes, really fragrant)
[Chongqing Guangdong education] Tianshui Normal University universe exploration reference
[IVX junior engineer training course 10 papers] 05 canvas and aircraft war game production
Mathematics - feelings -20220215
Learning notes 25 - multi sensor front fusion technology
遊戲思考15:全區全服和分區分服的思考
Variables and constants of go language foundation