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

边栏推荐
- [IVX junior engineer training course 10 papers] 04 canvas and a group photo of IVX and me
- Single chip microcomputer -- hlk-w801 transplant NES simulator (III)
- 技术大佬准备就绪,话题C位由你决定
- 站在新的角度来看待产业互联网,并且去寻求产业互联网的正确方式和方法
- Basic number theory -- Gauss elimination
- Global and Chinese market of aircraft MRO software 2022-2028: Research Report on technology, participants, trends, market size and share
- 企业应该选择无服务器计算吗?
- How does schedulerx help users solve the problem of distributed task scheduling?
- Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
- Penser au jeu 15: penser au service complet et au sous - service
猜你喜欢

Data visualization in medical and healthcare applications

Basic concepts of machine learning

Penser au jeu 15: penser au service complet et au sous - service

6-2 vulnerability exploitation - inevitable problems of FTP

迁移云计算工作负载的四个基本策略

6-3漏洞利用-SSH环境搭建

Infiltration records of CFS shooting range in the fourth phase of the western regions' Dadu Mansion
![[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games](/img/69/44219af52baef20cedec3870147589.jpg)
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games

电商系统中常见的9大坑,你踩过没?

6-2漏洞利用-ftp不可避免的问题
随机推荐
Brief description of grafana of # yyds dry goods inventory # Prometheus
This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable
Since I understand the idea of dynamic planning, I have opened the door to a new world
Part 29 supplement (XXIX) basis of ECMAScript
How does schedulerx help users solve the problem of distributed task scheduling?
Cat Party (Easy Edition)
Global and Chinese market of safety detection systems 2022-2028: Research Report on technology, participants, trends, market size and share
Learning note 3 -- Key Technologies of high-precision map (Part 1)
[image enhancement] vascular image enhancement based on frangi filter with matlab code
Global and Chinese market of aircraft MRO software 2022-2028: Research Report on technology, participants, trends, market size and share
Mathematics - feelings -20220215
Global and Chinese market of avionics systems 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets of digital crosspoint switches and mux/demux 2022-2028: Research Report on technology, participants, trends, market size and share
Have you stepped on the nine common pits in the e-commerce system?
6-2漏洞利用-ftp不可避免的问题
Develop a simple login logic based on SSM
No converter found for return value of type: class
Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
I Brief introduction of radio energy transmission technology
MySQL winter vacation self-study 2022 12 (4)