clc;
clear;
close all;
warning off;
addpath(genpath(pwd));
%****************************************************************************
%更多关于matlab和fpga的搜索“fpga和matlab”的CSDN博客:
%matlab/FPGA项目开发合作
%https://blog.csdn.net/ccsss22?type=blog
%****************************************************************************
envelope_insensitivity = 100;
silent_amplitude_threshold = 0.01;
%
filename = 'Test_DTMF.wav';
info = audioinfo(filename);
[y, Fs] = audioread(filename);
row_freq = [697; 770; 852; 941];
column_freq = [1209, 1336, 1477, 1633];
freqs = row_freq + column_freq;
chars = {{'1', '2', '3', 'A'}; {'4', '5', '6', 'B'}; ...
{'7', '8', '9', 'C'}; {'*', '0', '#', 'D'}};
num_strokes = 0;
prev_size = 0;
while (~(prev_size == length(y)))
prev_size = length(y);
envelope = imdilate(abs(y), true(envelope_insensitivity, 1));
if (num_strokes == 0)
figure;
plot(y); xlabel('Samples'); ylabel('Amplitude');
title('Signal');
hold on;
plot(envelope, 'r-', 'LineWidth', 2);
plot(-envelope, 'r-', 'LineWidth', 2);
legend('Data', 'Envelope');
end
quiet_parts = envelope < silent_amplitude_threshold;
stroke_num_samples = find(quiet_parts == 1, 1, 'first') - 1;
quiet_parts_cut = quiet_parts; quiet_parts_cut(1:stroke_num_samples) = [];
quiet_num_samples = find(quiet_parts_cut == 0, 1, 'first') - 1;
stroke = y(1:stroke_num_samples, :);
% the two frequencies that produce maximum power spectral density (PSD)
% are almost equal to the dual frequencies
[Pxx, F] = periodogram(stroke, rectwin(length(stroke)), length(stroke), Fs);
[~, index] = max(Pxx);
freq1 = F(index);
Pxx(index) = []; [~, index] = max(Pxx);
freq2 = F(index);
y(1:stroke_num_samples + quiet_num_samples, :) = [];
num_strokes = num_strokes + 1;
freq_estimated = round(freq1 + freq2); %estimated dual tone frequency
distance_squared = (freqs - freq_estimated) .^ 2; %distance of estimated frequency from actual dual tone frequencies
[row, column] = find(distance_squared == min(min(distance_squared))); %nearest frequency to the estimation is selected
fprintf('%c ', chars{row}{column});
end
fprintf('\nNumber of key strokes: %d\n', num_strokes);
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1.领域:matlab,基于DTMF的语音信号包络提取算法 2.内容:【含操作视频】基于DTMF的语音信号包络提取matlab仿真 3.用处:用于基于DTMF的语音信号包络提取算法编程学习 4.指向人群:本硕博等教研学习使用 5.运行注意事项: 使用matlab2021a或者更高版本测试,运行里面的Runme_.m文件,不要直接运行子函数文件。运行时注意matlab左侧的当前文件夹窗口必须是当前工程所在路径。 具体可观看提供的操作录像视频跟着操作。
资源推荐
资源详情
资源评论
收起资源包目录
基于DTMF的语音信号包络提取matlab仿真.rar (3个子文件)
操作录像0025.avi 2.63MB
Runme_DTMF.m 2KB
Test_DTMF.wav 98KB
共 3 条
- 1
资源评论
- zhuweiye121382023-05-02这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
- LIJIAN12392023-12-29简直是宝藏资源,实用价值很高,支持!
fpga和matlab
- 粉丝: 15w+
- 资源: 2548
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功