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

边栏推荐
- Ubuntu20.04 PostgreSQL 14 installation configuration record
- Architecture evolution from MVC to DDD
- How can I batch produce the same title for the video?
- Data visualization in medical and healthcare applications
- About asp Net core uses a small detail of datetime date type parameter
- The author is more willing to regard industrial Internet as a concept much richer than consumer Internet
- MySQL winter vacation self-study 2022 12 (4)
- Exclusive delivery of secret script move disassembly (the first time)
- How does schedulerx help users solve the problem of distributed task scheduling?
- Basic concepts of machine learning
猜你喜欢

GL Studio 5 installation and experience

Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
![[WesternCTF2018]shrine writeup](/img/26/1700095c9b38b9b74a1b1136e5d5de.jpg)
[WesternCTF2018]shrine writeup

Minimize the error

II Basic structure of radio energy transmission system

企业应该选择无服务器计算吗?

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

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

Hcip day 14 (MPLS protocol)

GL Studio 5 安装与体验
随机推荐
Global and Chinese market of aircraft MRO software 2022-2028: Research Report on technology, participants, trends, market size and share
uTools
Load and domcontentloaded in JS
Part 29 supplement (XXIX) basis of ECMAScript
Basic number theory -- Gauss elimination
Minimize the error
Laravel artisan 常用命令
Data visualization in medical and healthcare applications
How does schedulerx help users solve the problem of distributed task scheduling?
Global and Chinese markets for context and location-based services 2022-2028: Research Report on technology, participants, trends, market size and share
Architecture evolution from MVC to DDD
Global and Chinese market of wireless chipsets 2022-2028: Research Report on technology, participants, trends, market size and share
学习笔记2--高精度地图定义及价值
10 minutes to get started quickly composition API (setup syntax sugar writing method)
微信小程序中使用tabBar
笔者更加愿意将产业互联网看成是一个比消费互联网要丰富得多的概念
It's already 30. Can you learn programming from scratch?
Global and Chinese markets of beverage seasoning systems 2022-2028: Research Report on technology, participants, trends, market size and share
Basic usage of three JS high-order functions --filter---map---reduce
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games