把一个人的声音变成别人的声音有二种:一种是:将一个人的声音,变成非特定人的声音,如:把男声变女声,或把小孩子声音变成老人声音。另一种是:将一个人的声音变成特定人的声音,有点像美国电影中那种,A可以通过就变音技术说出B的声音。
此技术应用领域:一是娱乐性的,如:聊天的最高声音---变音聊天。 二是:有关保密方面,如某长官发布命令,在传播过程中进行变音,让敌方猜不出已方的领导人的身份。三是:被坏人利用。哈哈!
一、变音一般性的描述:
朋友们平常网上聊天大多是打字聊天! 即累又费时!稍微流行点的就是使用麦克风"摄像头类的东东改变一下聊天的氛围!另类的聊天境界你体验过吗? 那就是可以将自己语音聊天时的声音更换的更有个性!比如:将自己极具磁性的声音,打造成一个极甜美的声音!怎么样!好玩吧?
一般的音频可以借助电脑声卡的设置再加一软件配合就能实现。
二、变音的主要算法原理
简单说几种:
最简单的是:通过对语音的采样率进行变化,就能改变声音,这种是最低的,且不易用参数进行控制。
别外一种是:提取反应该个性的参数,如,男人、女人;小孩和老人,因声道的长度不一样,导致其基音不一样,进而导致各谐振峰不一样。我们可能通过改变基音和谐振峰的位置来改变声音。
-
function varargout = sound_process(varargin)
-
% SOUND_PROCESS MATLAB code for sound_process.fig
-
% SOUND_PROCESS, by itself, creates a new SOUND_PROCESS or raises the existing
-
% singleton*.
-
%
-
% H = SOUND_PROCESS returns the handle to a new SOUND_PROCESS or the handle to
-
% the existing singleton*.
-
%
-
% SOUND_PROCESS('CALLBACK',hObject,eventData,handles,...) calls the local
-
% function named CALLBACK in SOUND_PROCESS.M with the given input arguments.
-
%
-
% SOUND_PROCESS('Property','Value',...) creates a new SOUND_PROCESS or raises the
-
% existing singleton*. Starting from the left, property value pairs are
-
% applied to the GUI before sound_process_OpeningFcn gets called. An
-
% unrecognized property name or invalid value makes property application
-
% stop. All inputs are passed to sound_process_OpeningFcn via varargin.
-
%
-
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
-
% instance to run (singleton)".
-
%
-
% See also: GUIDE, GUIDATA, GUIHANDLES
-
-
% Edit the above text to modify the response to help sound_process
-
-
% Last Modified by GUIDE v2.5 03-Sep-2019 22:07:30
-
-
% Begin initialization code - DO NOT EDIT
-
gui_Singleton =
1;
-
gui_State = struct(
'gui_Name', mfilename, ...
-
'gui_Singleton', gui_Singleton, ...
-
'gui_OpeningFcn', @sound_process_OpeningFcn, ...
-
'gui_OutputFcn', @sound_process_OutputFcn, ...
-
'gui_LayoutFcn', [] , ...
-
'gui_Callback', []);
-
if nargin && ischar(varargin{
1})
-
gui_State.gui_Callback = str2func(varargin{
1});
-
end
-
-
if nargout
-
[varargout{
1:nargout}] = gui_mainfcn(gui_State, varargin{:});
-
else
-
gui_mainfcn(gui_State, varargin{:});
-
end
-
% End initialization code - DO NOT EDIT
-
-
-
% --- Executes just before sound_process is made visible.
-
function sound_process_OpeningFcn(hObject, eventdata, handles, varargin)
-
% This function has no output args, see OutputFcn.
-
% hObject handle to figure
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
% varargin command line arguments to sound_process (see VARARGIN)
-
-
% Choose default command line output for sound_process
-
handles.output = hObject;
-
handles.h1 = [handles.voice_change,handles.voice_code,handles.exit,handles.func_choose];
%功能选择界面句柄
-
handles.h2 = [handles.file_choose1,handles.back1,handles.stop1,handles.panel1, ...
-
handles.play_origin,handles.play_woman,handles.play_fast,handles.play_slow];
%变声器界面
-
handles.h3 = [handles.file_choose2,handles.back2,handles.figure,handles.play_origin2,...
-
handles.play_code,handles.draw_origin,handles.draw_code];
%语音加密界面
-
global a1 b1 c1 a2 b2 c2;
%文件打开的状态参量
-
c1 =
0;
-
c2 =
0;
-
global origin_voice1 origin_voice2 man_voice woman_voice ;
%
-
% Update handles structure
-
guidata(hObject, handles);
-
-
% UIWAIT makes sound_process wait for user response (see UIRESUME)
-
% uiwait(handles.figure1);
-
-
-
% --- Outputs from this function are returned to the command line.
-
function varargout = sound_process_OutputFcn(hObject, eventdata, handles)
-
% varargout cell array for returning output args (see VARARGOUT);
-
% hObject handle to figure
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
-
% Get default command line output from handles structure
-
varargout{
1} = handles.output;
-
-
-
% --- Executes on button press in voice_change.
-
function voice_change_Callback(hObject, eventdata, handles)
-
% hObject handle to voice_change (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
set(handles.h1,
'Visible',
'off');
-
set(handles.h2,
'Visible',
'on');
-
-
% --- Executes on button press in voice_code.
-
function voice_code_Callback(hObject, eventdata, handles)
-
% hObject handle to voice_code (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
set(handles.h1,
'Visible',
'off');
-
set(handles.h3,
'Visible',
'on');
-
-
% --- Executes on button press in exit.
-
function exit_Callback(hObject, eventdata, handles)
-
% hObject handle to exit (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
%按退出键退出当前程序
-
clear sound;
-
try
-
delete(sound_process);
-
end
-
-
-
% --- Executes on button press in file_choose1.
-
function file_choose1_Callback(hObject, eventdata, handles)
-
% hObject handle to file_choose1 (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
clear sound;
-
global a1 b1 c1 ;
-
[a1,b1,c1] = uigetfile(
'.wav',
'选择原始声音文件');
-
if c1 ==
0
-
warndlg(
'请选择音频文件',
'警告');
-
end
-
-
% --- Executes during object creation, after setting all properties.
-
function func_choose_CreateFcn(hObject, eventdata, handles)
-
% hObject handle to func_choose (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles empty - handles not created until after all CreateFcns called
-
-
-
% --- Executes on button press in back1.
-
function back1_Callback(hObject, eventdata, handles)
-
% hObject handle to back1 (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
clear sound;
-
set(handles.h1,
'Visible',
'on');
-
set(handles.h2,
'Visible',
'off');
-
set(handles.h2,
'Visible',
'off');
-
c1 =
0;
-
try
-
delete(allchild(handles.h2));
-
end
-
-
% --- Executes on button press in file_choose2.
-
function file_choose2_Callback(hObject, eventdata, handles)
-
% hObject handle to file_choose2 (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
clear sound;
-
global a2 b2 c2;
-
[a2,b2,c2] = uigetfile(
'.wav',
'选择原始声音文件');
-
if c2 ==
0
-
warndlg(
'请选择音频文件',
'警告');
-
end
-
% --- Executes on button press in back2.
-
function back2_Callback(hObject, eventdata, handles)
-
% hObject handle to back2 (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
clear sound;
-
set(handles.h1,
'Visible',
'on');
-
set(handles.h2,
'Visible',
'off');
-
set(handles.h3,
'Visible',
'off');
-
c2 =
0;
-
try
-
delete(allchild(handles.figure));
-
delete(allchild(handles.h3));
-
end
-
-
-
% --- Executes during object creation, after setting all properties.
-
function panel1_CreateFcn(hObject, eventdata, handles)
-
% hObject handle to panel1 (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles empty - handles not created until after all CreateFcns called
-
-
-
% --- Executes on button press in play_origin.
-
function play_origin_Callback(hObject, eventdata, handles)
-
% hObject handle to play_origin (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
clear sound;
-
global a1 b1 c1 origin_voice1;
-
if c1 ==
0
-
warndlg(
'请先选择音频文件',
'警告');
-
else
-
origin_voice1=[b1,a1];
-
fs =
22050;
-
[audio1,fs] = audioread(origin_voice1);
-
sound(audio1,fs);
-
end
-
-
% --- Executes on button press in play_woman.
-
function play_woman_Callback(hObject, eventdata, handles)
-
% hObject handle to play_woman (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
clear sound;
-
global a1 b1 c1 origin_voice1;
-
if c1 ==
0
-
warndlg(
'请先选择音频文件',
'警告');
-
-
% --- Executes on button press in draw_code.
-
function draw_code_Callback(hObject, eventdata, handles)
-
% hObject handle to draw_code (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles structure with handles and user data (see GUIDATA)
-
global a2 b2 c2 origin_voice2;
-
if c2 ==
0
-
warndlg(
'请先选择音频文件',
'警告');
-
else
-
origin_voice2=[b2,a2];
-
fs =
22050;
-
[audio2,fs] = audioread(origin_voice2);
-
x1=audio2(:,
1);
%取单列
-
N=length(x1);
-
n=
0:N-
1;
-
t=(
0:(N-
1))/fs;
-
y1 = cos(
50000 * t);
-
e = x1 .* y1';
-
f=
0:fs/N:fs*(N-
1)/N;
-
w=
400000*f/fs;
-
A3=fft(e,N);
-
plot(handles.figure,w,abs(A3));
-
end
-
-
% --- Executes during object creation, after setting all properties.
-
function figure_CreateFcn(hObject, eventdata, handles)
-
% hObject handle to figure (see GCBO)
-
% eventdata reserved - to be defined in a future version of MATLAB
-
% handles empty - handles not created until after all CreateFcns called
-
-
% Hint: place code in OpeningFcn to populate figure
-
-
-
% --- Executes on button press in play_slow.
-
function play_slow_Callback(hObject, eventdata, handles)
-
% hObject handle to play_slow (see GCBO)
-
% eventd
完整代码或仿真咨询QQ1575304183
转载:https://blog.csdn.net/m0_57702748/article/details/117266705
查看评论