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

边栏推荐
- [image enhancement] vascular image enhancement based on frangi filter with matlab code
- GL Studio 5 installation and experience
- NeRV: Neural Reflectance and Visibility Fields for Relighting and View Synthesis
- How does schedulerx help users solve the problem of distributed task scheduling?
- Minimize the error
- Mathematics - feelings -20220215
- [rust web rokcet Series 2] connect the database and add, delete, modify and check curd
- Global and Chinese markets for context and location-based services 2022-2028: Research Report on technology, participants, trends, market size and share
- Global and Chinese markets of edge AI software 2022-2028: Research Report on technology, participants, trends, market size and share
- How can I batch produce the same title for the video?
猜你喜欢
![[IVX junior engineer training course 10 papers] 06 database and services](/img/68/967566fc2f1d0b93ecd78bdb208b64.jpg)
[IVX junior engineer training course 10 papers] 06 database and services

Unity AssetBundle subcontracting

Minimize the error

This is the report that leaders like! Learn dynamic visual charts, promotion and salary increase are indispensable

Learning note 24 - multi sensor post fusion technology

The concept and application of Cartland number
![[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production](/img/b7/aecb815ca9545981563a1e16cfa19e.jpg)
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production

GL Studio 5 installation and experience

Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)

浅浅了解Servlet
随机推荐
Basic number theory -- Gauss elimination
Global and Chinese markets for distributed generation and energy storage in telecommunications networks 2022-2028: Research Report on technology, participants, trends, market size and share
What are the differences between software testers with a monthly salary of 7K and 25K? Leaders look up to you when they master it
Raspberry pie 4B learning notes - IO communication (1-wire)
Load and domcontentloaded in JS
Basic usage of three JS high-order functions --filter---map---reduce
Based on Simulink and FlightGear, the dynamic control of multi rotor UAV in equilibrium is modeled and simulated
Exclusive delivery of secret script move disassembly (the first time)
Cat Party (Easy Edition)
How can I batch produce the same title for the video?
Leetcode, 3 repeatless longest subsequence
[Chongqing Guangdong education] Tianshui Normal University universe exploration reference
Luogu p1775 stone merger (weakened version)
Appium inspector can directly locate the WebView page. Does anyone know the principle
Comprehensive broadcast of global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
Learn C language from scratch day 025 (maze)
Fastadmin controls the length of fields in the table
Daily work and study notes
学习笔记2--高精度地图定义及价值