WO2020258503A1 - 基于Tensorflow的语音融合方法、电子装置及存储介质 - Google Patents

基于Tensorflow的语音融合方法、电子装置及存储介质 Download PDF

Info

Publication number
WO2020258503A1
WO2020258503A1 PCT/CN2019/103573 CN2019103573W WO2020258503A1 WO 2020258503 A1 WO2020258503 A1 WO 2020258503A1 CN 2019103573 W CN2019103573 W CN 2019103573W WO 2020258503 A1 WO2020258503 A1 WO 2020258503A1
Authority
WO
WIPO (PCT)
Prior art keywords
voice
style
content
tensorflow
spectrogram
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2019/103573
Other languages
English (en)
French (fr)
Inventor
张鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Publication of WO2020258503A1 publication Critical patent/WO2020258503A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L21/00Speech or voice signal processing techniques to produce another audible or non-audible signal, e.g. visual or tactile, in order to modify its quality or its intelligibility
    • G10L21/003Changing voice quality, e.g. pitch or formants
    • G10L21/007Changing voice quality, e.g. pitch or formants characterised by the process used
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L25/00Speech or voice analysis techniques not restricted to a single one of groups G10L15/00 - G10L21/00
    • G10L25/03Speech or voice analysis techniques not restricted to a single one of groups G10L15/00 - G10L21/00 characterised by the type of extracted parameters
    • G10L25/18Speech or voice analysis techniques not restricted to a single one of groups G10L15/00 - G10L21/00 characterised by the type of extracted parameters the extracted parameters being spectral information of each sub-band
    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L25/00Speech or voice analysis techniques not restricted to a single one of groups G10L15/00 - G10L21/00
    • G10L25/27Speech or voice analysis techniques not restricted to a single one of groups G10L15/00 - G10L21/00 characterised by the analysis technique
    • G10L25/30Speech or voice analysis techniques not restricted to a single one of groups G10L15/00 - G10L21/00 characterised by the analysis technique using neural networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • This application relates to the field of artificial intelligence technology, and in particular to a Tensorflow-based voice fusion method, electronic device, and computer-readable storage medium.
  • the current voice fusion provides users with many needs and conveniences, but the fusion of different styles of voice cannot be achieved in the voice system.
  • voice fusion That is to say, how to capture the features of the content voice and style voice files separately, merge the two features through deep learning, and then synthesize a new voice into a possibility. That is: how to transfer one voice style to another different voice.
  • This application provides a Tensorflow-based voice fusion method, electronic device, and computer-readable storage medium. Its main purpose is to merge different styles of voice based on Tensorflow, automatically add background music to the voice, and intelligently create new music. So as to provide users with more convenience and better experience.
  • this application provides a Tensorflow-based voice fusion method, which includes:
  • the content voice data and style voice data to be fused after ISTFT and other transformation processing are synthesized into MP3 format voice through librosa.
  • the present application also provides an electronic device, which includes a memory and a processor.
  • the memory includes a Tensorflow-based voice fusion program.
  • the Tensorflow-based voice fusion program is executed by the processor, Implement the following steps:
  • the content voice data and style voice data to be fused after ISTFT and other transformation processing are synthesized into MP3 format voice through librosa.
  • the present application also provides a computer non-volatile readable storage medium
  • the computer non-volatile readable storage medium includes a Tensorflow-based voice fusion program, the Tensorflow-based voice fusion
  • the program is executed by the processor, any step in the Tensorflow-based voice fusion method described above is realized.
  • the Tensorflow-based voice fusion method, electronic device, and computer non-volatile readable storage medium proposed in this application extract the acoustic features of content voice and style voice through Tensorflow's filter template, and create a loss function through Tensorflow's optimizer
  • the loss function is iteratively optimized to determine the content voice data and style voice data to be merged, and the content voice data and style voice data to be merged are merged through librosa, so as to realize the fusion of voices of different styles. Sound automatically adds background music and intelligently creates new music, so as to provide users with more convenience and better experience.
  • FIG. 1 is a schematic diagram of an application environment of a preferred embodiment of a voice fusion method based on Tensorflow in this application;
  • FIG. 2 is a schematic diagram of modules of a preferred embodiment of the Tensorflow-based voice fusion program in FIG. 1;
  • Fig. 3 is a flowchart of a preferred embodiment of a voice fusion method based on Tensorflow in this application.
  • This application provides a voice fusion method based on Tensorflow, which is applied to an electronic device 1.
  • FIG. 1 it is a schematic diagram of the application environment of the preferred embodiment of the Tensorflow-based voice fusion method of this application.
  • the electronic device 1 may be a terminal device with arithmetic function, such as a server, a smart phone, a tablet computer, a portable computer, a desktop computer, and the like.
  • the electronic device 1 includes a processor 12, a memory 11, a network interface 14 and a communication bus 15.
  • the memory 11 includes at least one type of readable storage medium.
  • the at least one type of readable storage medium may be a non-volatile storage medium such as flash memory, hard disk, multimedia card, card-type memory 11, and the like.
  • the readable storage medium may be an internal storage unit of the electronic device 1, such as a hard disk of the electronic device 1.
  • the readable storage medium may also be the external memory 11 of the electronic device 1, such as a plug-in hard disk or a smart memory card (Smart Media Card, SMC) equipped on the electronic device 1. , Secure Digital (SD) card, Flash Card, etc.
  • SD Secure Digital
  • the readable storage medium of the memory 11 is generally used to store the Tensorflow-based speech fusion program 10, filter templates, and TensorFlow optimizer installed in the electronic device 1.
  • the memory 11 can also be used to temporarily store data that has been output or will be output.
  • the processor 12 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program codes or process data stored in the memory 11, for example, perform character emotion analysis Procedure 10 etc.
  • CPU central processing unit
  • microprocessor or other data processing chip, used to run program codes or process data stored in the memory 11, for example, perform character emotion analysis Procedure 10 etc.
  • the network interface 14 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface), and is generally used to establish a communication connection between the electronic device 1 and other electronic devices.
  • the communication bus 15 is used to realize the connection and communication between these components.
  • FIG. 1 only shows the electronic device 1 with the components 11-15, but it should be understood that it is not required to implement all the illustrated components, and more or fewer components may be implemented instead.
  • the electronic device 1 may also include a user interface.
  • the user interface may include an input unit such as a keyboard (Keyboard), a voice input device such as a microphone (microphone) and other devices with voice recognition functions, and a voice output device such as audio, earphones, etc.
  • the user interface may also include a standard wired interface and a wireless interface.
  • the electronic device 1 may also include a display, and the display may also be called a display screen or a display unit.
  • the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an organic light-emitting diode (Organic Light-Emitting Diode, OLED) touch device.
  • OLED Organic Light-Emitting Diode
  • the display is used for displaying information processed in the electronic device 1 and for displaying a visualized user interface.
  • the electronic device 1 further includes a touch sensor.
  • the area provided by the touch sensor for the user to perform a touch operation is called a touch area.
  • the touch sensor described here may be a resistive touch sensor, a capacitive touch sensor, or the like.
  • the touch sensor includes not only a contact type touch sensor, but also a proximity type touch sensor and the like.
  • the touch sensor may be a single sensor, or may be, for example, a plurality of sensors arranged in an array.
  • the area of the display of the electronic device 1 may be the same as or different from the area of the touch sensor.
  • the display and the touch sensor are stacked to form a touch display screen. The device detects the touch operation triggered by the user based on the touch screen.
  • the electronic device 1 may also include a radio frequency (RF) circuit, a sensor, an audio circuit, etc., which will not be repeated here.
  • RF radio frequency
  • the memory 11 as a computer storage medium may include an operating system and a Tensorflow-based voice fusion program 10; the processor 12 executes the Tensorflow-based voice fusion program stored in the memory 11. The following steps are implemented at 10 o'clock:
  • the content voice data and style voice data to be fused after ISTFT and other transformation processing are synthesized into MP3 format voice through librosa.
  • the content voice is converted into the content voice floating point data
  • the style voice is converted into the style voice floating point data
  • librosa is a python toolkit for audio and music analysis and processing. Some common time-frequency processing, feature extraction, drawing sound graphics and other functions are all available and powerful.
  • the purpose of loading two voices is to clarify which voice is being operated, that is, what are the content voice and style voice that you want to merge.
  • the voice itself is a file in the wav format.
  • the data (float floating point data) converted into the wav format needs to be placed in the computer memory for subsequent steps.
  • the acquired content voice floating point data and style voice floating point data are converted into content voice spectrogram and style voice spectrogram through STFT and other changes.
  • STFT Short Time Leaf Transform
  • the sound spectrogram is drawn using STFT, and its essence is the energy of STFT, that is, the square of the modulus.
  • the STFT function of librosa is called to realize the conversion of floating-point data to spectrogram. That is: the content voice and style voice are converted from floating point data into content voice spectrogram and style voice spectrogram by calling the STFT function of librosa.
  • feature extraction is performed on the content speech spectrogram and the style speech spectrogram respectively through a filter template to obtain the acoustic characteristics of the content speech and the acoustic characteristics of the style speech.
  • a filter template to obtain the acoustic characteristics of the content speech and the acoustic characteristics of the style speech.
  • the filter template is actually the feature extraction of the spectrum obtained above.
  • the method used is to use the tf.nn.conv2d method of the convolutional neural network, in which the convolution kernel is customized (such as: randomly generating a certain dimension array multiplied by one Coefficient), like extracting some values at higher latitudes to represent the original larger and more informative speech.
  • the current extraction of content voice and style voice features is not very accurate, but the fused voice can be generated approximately, that is, the new voice after fusion has content from the original content voice and style voice.
  • tf.nn.conv2d is a function that implements convolution in Tensorflow, which is a core method for building convolutional neural networks.
  • the first parameter input refers to the input image that needs to be convolved. It requires a Tensor with a shape like [batch, in_height, in_width, in_channels]. The specific meaning is [the number of images in a batch during training, the height of the image, Image width, image channel number], note that this is a 4-dimensional Tensor, which requires one of float32 and float64;
  • the second parameter filter equivalent to the convolution kernel in CNN, it requires a Tensor with a shape like [filter_height, filter_width, in_channels, out_channels], the specific meaning is [height of convolution kernel, width of convolution kernel , The number of image channels, the number of convolution kernels], the required type is the same as the parameter input, there is one thing to note, the third dimension in_channels is the fourth dimension of the parameter input;
  • the fourth parameter padding the amount of string type, which can only be one of "SAME” and "VALID”. This value determines different convolution methods
  • the newly created X list is the initial list variable (it can also be thought of as the creation of a Tensorflow tensor), and its data represents the newly generated fusion speech data. It's just that the value is empty when it is initialized, and the data inside must be modified through machine learning to finally approach the value of the real synthesized speech.
  • l total represents the total difference
  • l style represents the style voice difference
  • l content represents the content voice difference
  • represents the style voice parameter
  • represents the content voice parameter
  • a represents the style voice feature value
  • p represents the content voice feature value
  • X represents the characteristic value of the variable.
  • the value of x When the value of x reaches a certain value, at this time, the obtained l total is the smallest (the loss function L does not have to be equal to 0, but can also be 0, as long as it is getting smaller and converging to a certain value) ,
  • the value of x is approximately equal to the style voice feature value, and approximately equal to the content voice feature value, where a and p can be regarded as the extracted feature values.
  • the value of X is determined to determine the data of the fusion voice.
  • the step of iteratively optimizing the loss function by Tensorflow optimizer includes:
  • the content voice feature value and the style voice feature value are determined, and then the content voice data and the style voice data to be merged are determined.
  • the content voice data and style voice data to be merged are transformed by ISTFT and the like.
  • This process is the inverse operation of the process of "converting content voice floating point data and style voice floating point data into content voice spectrogram and style voice spectrogram through STFT and other changes", and will obtain the content voice data and style voice to be merged Data, the frequency domain of the acquired speech is converted into the time domain, and finally the speech is regenerated from the time domain.
  • time-domain analysis of signals is performed, sometimes the time-domain parameters of some signals are the same, but it does not mean that the signals are exactly the same.
  • two signals with the same function structure may not be the same, because the signal not only changes with time, but is also related to information such as frequency and phase, which requires further analysis of the signal's frequency structure and description of the signal in the frequency domain.
  • the transformation of dynamic signals from time domain to frequency domain is mainly realized by Fourier series and Fourier transform.
  • Periodic signals rely on Fourier series, and non-periodic signals rely on Fourier transform.
  • the time domain function is transformed into a frequency domain function through Fourier or Laplace transform.
  • the Fourier transform can convert a time domain signal into the corresponding amplitude and phase at different frequencies.
  • the frequency spectrum is the performance of the time domain signal in the frequency domain, and the inverse Fourier transform can convert the frequency spectrum back to the time domain. signal.
  • the electronic device 1 proposed in the above embodiment extracts the acoustic features of content voice and style voice through the filter template of Tensorflow, and creates a loss function.
  • the loss function is iteratively optimized through the optimizer of Tensorflow to determine the content voice to be fused Data and style voice data.
  • the content voice data and style voice data to be merged are merged, so as to realize the fusion of different styles of voice, automatically add background music to the voice, and intelligently create new music, so as to provide users with More convenience and better experience.
  • the Tensorflow-based speech fusion program 10 may also be divided into one or more modules, and the one or more modules are stored in the memory 11 and executed by the processor 12 to complete the application.
  • the module referred to in this application refers to a series of computer program instruction segments that can complete specific functions.
  • FIG. 2 it is a program module diagram of a preferred embodiment of the Tensorflow-based speech fusion program 10 in FIG. 1.
  • the Tensorflow-based voice fusion program 10 can be divided into: a spectrogram acquisition module 110, an acoustic feature acquisition module 120, a loss function creation module 130, a voice data acquisition module 140 to be fused, a conversion module 150 such as ISTFT, and a voice fusion module 160 .
  • the functions or operation steps implemented by the modules 110-160 are similar to the above, and will not be described in detail here. For example, for example:
  • the spectrogram acquisition module 110 is configured to convert content voice floating point data and style voice floating point data into content voice spectrogram and style voice spectrogram through STFT and other changes;
  • the acoustic feature acquisition module 120 is configured to perform feature extraction on the content speech spectrogram and the style speech spectrogram respectively through a filter template, to obtain the acoustic features of the content speech and the acoustic characteristics of the style speech;
  • the loss function creation module 130 is configured to create a loss function according to the acoustic features of the content voice and the acoustic features of the style voice;
  • the to-be-fused voice data acquisition module 140 is configured to iteratively optimize the loss function through the optimizer of Tensorflow, and determine the content voice data and style voice data to be fused when the difference of the loss function is the smallest;
  • the ISTFT and other conversion module 150 is used to perform ISTFT and other conversions on the content voice data and style voice data to be fused;
  • the voice fusion module 160 is used to synthesize the voice in MP3 format from the content voice data and style voice data to be fused after ISTFT and other transformation processing by librosa.
  • the voice fusion program 10 based on Tensorflow further includes a voice loading module.
  • the voice loading module is used for loading content voice and style voice through librosa; converting the content voice into the content voice floating point data, and converting the style voice into the style voice floating point number according to.
  • this application also provides a voice fusion method based on Tensorflow.
  • FIG. 3 it is a flowchart of a preferred embodiment of a voice fusion method based on Tensorflow in this application.
  • the method can be executed by a device, and the device can be implemented by software and/or hardware.
  • the voice fusion method based on Tensorflow includes: step S10 to step S60.
  • Step S10 Convert content voice floating point data and style voice floating point data into content voice spectrogram and style voice spectrogram through STFT and other changes;
  • Step S20 Perform feature extraction on the content speech spectrogram and the style speech spectrogram respectively through a filter template to obtain the acoustic features of the content speech and the acoustic characteristics of the style speech;
  • Step S30 Create a loss function according to the acoustic features of the content voice and the acoustic features of the style voice;
  • Step S40 Iteratively optimize the loss function through the optimizer of Tensorflow, and determine the content voice data and style voice data to be fused when the difference of the loss function is the smallest;
  • Step S50 Perform ISTFT and other transformations on the content voice data and style voice data to be merged;
  • Step S60 The content voice data and style voice data to be merged after the ISTFT conversion processing is synthesized by librosa into MP3 format voice.
  • step S10 the following steps are also included before step S10:
  • the content voice is converted into the content voice floating point data
  • the style voice is converted into the style voice floating point data
  • librosa is a python toolkit for audio and music analysis and processing. Some common time-frequency processing, feature extraction, drawing sound graphics and other functions are all available and powerful.
  • the purpose of loading two voices is to clarify which voice is being operated, that is, what are the content voice and style voice that you want to merge.
  • the voice itself is a file in the wav format.
  • the data (float floating point data) converted into the wav format needs to be placed in the computer memory for subsequent steps.
  • step S10 the acquired content voice floating point data and style voice floating point data are converted into content voice spectrogram and style voice spectrogram through STFT and other changes.
  • STFT Short Time Leaf Transform
  • the sound spectrogram is drawn using stft, and its essence is the energy of stft, which is the square of the modulus.
  • the stft function of librosa is called to realize the conversion of floating-point data to a spectrogram. That is: the content voice and style voice are converted from floating point data into content voice spectrogram and style voice spectrogram by calling the stft function of librosa.
  • step S20 feature extraction is performed on the content speech spectrogram and the style speech spectrogram respectively through a filter template, and the acoustic features of the content speech and the acoustic characteristics of the style speech are obtained. Namely: Create a new filter template to capture the acoustic characteristics of content voice and style voice respectively.
  • the filter template is actually the feature extraction of the frequency spectrum obtained in step S10.
  • the method used is to use the tf.nn.conv2d method of the convolutional neural network, where the convolution kernel is customized (such as: randomly generating a certain dimension of array multiplying by A coefficient), like extracting some values at higher latitudes to represent the original larger and more informative speech.
  • the current extraction of content voice and style voice features is not very accurate, but the fused voice can be generated approximately, that is, the new voice after fusion has content from the original content voice and style voice.
  • tf.nn.conv2d is a function that implements convolution in Tensorflow, which is a core method for building convolutional neural networks.
  • the first parameter input refers to the input image that needs to be convolved. It requires a Tensor with a shape like [batch, in_height, in_width, in_channels]. The specific meaning is [the number of images in a batch during training, the height of the image, Image width, image channel number], note that this is a 4-dimensional Tensor, which requires one of float32 and float64;
  • the second parameter filter equivalent to the convolution kernel in CNN, it requires a Tensor with a shape like [filter_height, filter_width, in_channels, out_channels], the specific meaning is [height of convolution kernel, width of convolution kernel , The number of image channels, the number of convolution kernels], the required type is the same as the parameter input, there is one thing to note, the third dimension in_channels is the fourth dimension of the parameter input;
  • the fourth parameter padding the amount of string type, which can only be one of "SAME” and "VALID”. This value determines different convolution methods
  • step S30 a loss function is created according to the acoustic features of the content voice and the acoustic features of the style voice.
  • a variable X list is built, and a loss function is built according to the acoustic characteristics.
  • the newly created X list is the initial list variable (it can also be thought of as the creation of a tensorflow tensor), and its data represents the newly generated fusion speech data. It's just that the value is empty when it is initialized, and the data inside must be modified through machine learning to finally approach the value of the real synthesized speech.
  • l total represents the total difference
  • l style represents the style voice difference
  • l content represents the content voice difference
  • represents the style voice parameter
  • represents the content voice parameter
  • a represents the style voice feature value
  • p represents the content voice feature value
  • X represents the characteristic value of the variable.
  • the value of x When the value of x reaches a certain value, at this time, the obtained l total is the smallest (the loss function L does not have to be equal to 0, but can also be 0, as long as it is getting smaller and converging to a certain value) ,
  • the value of x is approximately equal to the style voice feature value, and approximately equal to the content voice feature value, where a and p can be regarded as the extracted feature values.
  • the value of X is determined to determine the data of the fusion voice.
  • Step S40 Iteratively optimize the loss function through the optimizer of Tensorflow, and determine the content voice data and style voice data to be fused when the difference of the loss function is the smallest.
  • the step of iteratively optimizing the loss function through the optimizer of Tensorfow includes:
  • the content voice feature value and the style voice feature value are determined, and then the content voice data and the style voice data to be merged are determined.
  • Step S50 Perform ISTFT and other transformations on the content voice data and style voice data to be merged.
  • the content voice data and the style voice data to be merged are transformed by ISTFT or the like.
  • This process is the reverse operation of the process of step S10, which converts the acquired content voice data and style voice data to be merged into the time domain, and finally regenerates the voice from the time domain.
  • time-domain analysis of signals is performed, sometimes the time-domain parameters of some signals are the same, but it does not mean that the signals are exactly the same.
  • two signals with the same function structure may not be the same, because the signal not only changes with time, but is also related to information such as frequency and phase, which requires further analysis of the signal's frequency structure and description of the signal in the frequency domain.
  • the transformation of dynamic signals from time domain to frequency domain is mainly realized by Fourier series and Fourier transform.
  • Periodic signals rely on Fourier series, and non-periodic signals rely on Fourier transform.
  • the time domain function is transformed into a frequency domain function through Fourier or Laplace transform.
  • the Fourier transform can convert a time domain signal into the corresponding amplitude and phase at different frequencies.
  • the frequency spectrum is the performance of the time domain signal in the frequency domain, and the inverse Fourier transform can convert the frequency spectrum back to the time domain. signal.
  • the acoustic features of content speech and style speech are extracted through Tensorflow's filter template, and a loss function is created.
  • the loss function is iteratively optimized by Tensorflow's optimizer to determine the The fused content voice data and style voice data, through librosa to merge the content voice data and style voice data to be fused, so as to achieve the fusion of different styles of voice, automatically add background music to the voice, and intelligently create new music. So as to provide users with more convenience and better experience.
  • an embodiment of the present application also proposes a computer-readable storage medium that includes a Tensorflow-based voice fusion program, and the Tensorflow-based voice fusion program implements the following operations when executed by a processor:
  • the content voice data and style voice data to be fused after ISTFT and other transformation processing are synthesized into MP3 format voice through librosa.
  • the content voice is converted into the content voice floating point data
  • the style voice is converted into the style voice floating point data
  • the step of performing feature extraction on the content speech spectrogram and the style speech spectrogram through the filter template respectively includes:
  • the filter template uses tf.nn.conv2d of the convolutional neural network to perform feature extraction on the content speech spectrogram and the style speech spectrogram respectively, wherein:
  • the tf.nn.conv2d of the convolutional neural network is a function of the convolutional neural network implemented based on Tensorflow.
  • the formula of the loss function is as follows:
  • l total represents the total difference
  • l style represents the style voice difference
  • l content represents content voice difference
  • represents style voice parameters
  • represents the content voice parameter
  • a represents the style voice feature value
  • p represents the content voice feature value
  • x represents the variable feature value
  • the step of iteratively optimizing the loss function through the optimizer of TensorFlow includes:
  • the content voice feature value and the style voice feature value are determined, and then the content voice data and the style voice data to be merged are determined.
  • the optimizer of Tensorflow is the L-BFGS-B algorithm.
  • the specific implementation of the computer-readable storage medium of the present application is substantially the same as the specific implementation of the Tensorflow-based voice fusion method and electronic device, and will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • Acoustics & Sound (AREA)
  • Multimedia (AREA)
  • Quality & Reliability (AREA)
  • Spectroscopy & Molecular Physics (AREA)
  • Artificial Intelligence (AREA)
  • Evolutionary Computation (AREA)
  • Circuit For Audible Band Transducer (AREA)
  • Machine Translation (AREA)

Abstract

一种基于Tensorflow的语音融合方法、电子装置及计算机可读存储介质,其中的方法包括:将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图(S10);通过过滤器模板分别对两种语音频谱图进行特征提取,获取两种语音的声学特征(S20),并创建loss函数(S30);通过Tensorflow的优化器对loss函数进行迭代优化,当loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据(S40);将待融合的语音数据进行ISTFT等变换(S50);通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音(S60)。通过基于Tensorflow将不同风格的语音融合在一起,为说话声自动增加背景音乐、智能创造新音乐,从而为用户提供更多地体验。

Description

基于Tensorflow的语音融合方法、电子装置及存储介质
本申请要求于2019年6月27日提交中国专利局,申请号为201910566906.2、发明名称为“基于Tensorflow的语音融合方法、电子装置及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及人工智能技术领域,尤其涉及一种基于Tensorflow的语音融合方法、电子装置及计算机可读存储介质。
背景技术
目前的语音融合为用户提供了很多需求和方便,但是在语音系统中还不能实现不同风格的语音进行融合。其中,随着深度学习技术的发展和应用,为语音融合提供可能。也就是说,如何分别捕获内容语音、风格语音文件的特征,通过深度学习,将两者的特征进行融合,再将其合成一条新语音成为一种可能。即:如何将一个语音风格迁移到另一条不同的语音。
目前为了满足用户将不同风格的语音进行融合的需求,亟需一种不同风格的语音融合的方法。
发明内容
本申请提供一种基于Tensorflow的语音融合方法、电子装置及计算机可读存储介质,其主要目的在于通过基于Tensorflow将不同风格的语音融合在一起,为说话声自动增加背景音乐、智能创造新音乐,从而为用户提供更多方便和更好地体验。
此外,为实现上述目的,本申请提供一种基于Tensorflow的语音融合方法,该方法包括:
将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行 特征提取,获取内容语音的声学特征和风格语音的声学特征;
根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
为实现上述目的,本申请还提供一种电子装置,该装置包括:存储器、处理器,所述存储器中包括基于Tensorflow的语音融合程序,所述基于Tensorflow的语音融合程序被所述处理器执行时实现如下步骤:
将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
此外,为实现上述目的,本申请还提供一种计算机非易失性可读存储介质,所述计算机非易失性可读存储介质中包括基于Tensorflow的语音融合程序,所述基于Tensorflow的语音融合程序被处理器执行时,实现如上所述的基于Tensorflow的语音融合方法中的任意步骤。
本申请提出的基于Tensorflow的语音融合方法、电子装置及计算机非易失性可读存储介质,通过Tensorflow的过滤器模板提取内容语音和风格语音的声学特征,并创建loss函数,通过Tensorflow的优化器对所述loss函数进行迭代优化,确定待融合的内容语音数据和风格语音数据,通过librosa将待融合的内容语音数据和风格语音数据进行融合,从而实现将不同风格的语音融合在一起,为说话声自动增加背景音乐、智能创造新音乐,从而为用户提 供更多方便和更好地体验。
附图说明
图1为本申请基于Tensorflow的语音融合方法较佳实施例的应用环境示意图;
图2为图1中基于Tensorflow的语音融合程序较佳实施例的模块示意图;
图3为本申请基于Tensorflow的语音融合方法较佳实施例的流程图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
具体实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。
本申请提供一种基于Tensorflow的语音融合方法,应用于一种电子装置1。参照图1所示,为本申请基于Tensorflow的语音融合方法较佳实施例的应用环境示意图。
在本实施例中,电子装置1可以是服务器、智能手机、平板电脑、便携计算机、桌上型计算机等具有运算功能的终端设备。
该电子装置1包括:处理器12、存储器11、网络接口14及通信总线15。
存储器11包括至少一种类型的可读存储介质。所述至少一种类型的可读存储介质可为如闪存、硬盘、多媒体卡、卡型存储器11等的非易失性存储介质。在一些实施例中,所述可读存储介质可以是所述电子装置1的内部存储单元,例如该电子装置1的硬盘。在另一些实施例中,所述可读存储介质也可以是所述电子装置1的外部存储器11,例如所述电子装置1上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。
在本实施例中,所述存储器11的可读存储介质通常用于存储安装于所述电子装置1的基于Tensorflow的语音融合程序10、过滤器模板及TensorFlow的优化器等。所述存储器11还可以用于暂时地存储已经输出或者将要输出的数据。
处理器12在一些实施例中可以是一中央处理器(Central Processing Unit,CPU),微处理器或其他数据处理芯片,用于运行存储器11中存储的程序代码或处理数据,例如执行人物情绪分析程序10等。
网络接口14可选地可以包括标准的有线接口、无线接口(如WI-FI接口),通常用于在该电子装置1与其他电子设备之间建立通信连接。
通信总线15用于实现这些组件之间的连接通信。
图1仅示出了具有组件11-15的电子装置1,但是应理解的是,并不要求实施所有示出的组件,可以替代的实施更多或者更少的组件。
可选地,该电子装置1还可以包括用户接口,用户接口可以包括输入单元比如键盘(Keyboard)、语音输入装置比如麦克风(microphone)等具有语音识别功能的设备、语音输出装置比如音响、耳机等,可选地用户接口还可以包括标准的有线接口、无线接口。
可选地,该电子装置1还可以包括显示器,显示器也可以称为显示屏或显示单元。在一些实施例中可以是LED显示器、液晶显示器、触控式液晶显示器以及有机发光二极管(Organic Light-Emitting Diode,OLED)触摸器等。显示器用于显示在电子装置1中处理的信息以及用于显示可视化的用户界面。
可选地,该电子装置1还包括触摸传感器。所述触摸传感器所提供的供用户进行触摸操作的区域称为触控区域。此外,这里所述的触摸传感器可以为电阻式触摸传感器、电容式触摸传感器等。而且,所述触摸传感器不仅包括接触式的触摸传感器,也可包括接近式的触摸传感器等。此外,所述触摸传感器可以为单个传感器,也可以为例如阵列布置的多个传感器。
此外,该电子装置1的显示器的面积可以与所述触摸传感器的面积相同,也可以不同。可选地,将显示器与所述触摸传感器层叠设置,以形成触摸显示屏。该装置基于触摸显示屏侦测用户触发的触控操作。
可选地,该电子装置1还可以包括射频(Radio Frequency,RF)电路,传感器、音频电路等等,在此不再赘述。
在图1所示的装置实施例中,作为一种计算机存储介质的存储器11中可以包括操作系统、以及基于Tensorflow的语音融合程序10;处理器12执行存储器11中存储的基于Tensorflow的语音融合程序10时实现如下步骤:
将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容 语音频谱图和风格语音频谱图;
通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
通过Tensorfow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
在本申请中,在将内容语音数据和风格语音数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图的步骤之前,还包括如下步骤:
通过librosa对内容语音和风格语音进行加载处理;
将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
其中,librosa是一个用于音频、音乐分析、处理的python工具包,一些常见的时频处理、特征提取、绘制声音图形等功能应有尽有,功能十分强大。
加载两条语音的目的是想明确所操作的语音是哪个,即想要融合的内容语音和风格语音各是什么。
语音本身是wav格式的文件,加载是需要把其中wav格式转化为的数据(float浮点数据)放到计算机内存中,以便后续的步骤。
接下来,将获取的内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图。其中,STFT(短时叶变换)是和傅里叶变换相关的一种数学变换,用以确定时变信号其局部区域正弦波的频率与相位。声音频谱图就是使用STFT绘制而成的,其实质就是STFT的能量,也就是模值的平方。
在本申请中,调用librosa的STFT函数实现浮点数据到频谱图的转换。即:通过调用librosa的STFT函数将内容语音和风格语音由浮点数据转化为内容语音频谱图和风格语音频谱图。
其中,通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征。即:新 建一个过滤器模板,分别捕获出内容语音和风格语音的声学特征。
过滤器模板其实是对上述得到的频谱做特征提取,采用的方式是用卷积神经网络的tf.nn.conv2d方法,其中卷积核是自定义(如:随机生成一定维度的数组乘以一个系数),就像在更高纬度抽取一些数值来代表原来更大、更多信息的语音。内容语音和风格语音特征当前抽取还不是非常准确,但可以近似的生成融合后的语音,即融合后的新语音有分别来自原来内容语音、风格语音的内容。
具体地,tf.nn.conv2d是Tensorflow里面实现卷积的函数,这是搭建卷积神经网络比较核心的一个方法。
tf.nn.conv2d(input,filter,strides,padding,use_cudnn_on_gpu=None,name=None)
除去name参数用以指定该操作的name,一共五个参数:
第一个参数input:指需要做卷积的输入图像,它要求是一个Tensor,具有[batch,in_height,in_width,in_channels]这样的shape,具体含义是[训练时一个batch的图片数量,图片高度,图片宽度,图像通道数],注意这是一个4维的Tensor,要求类型为float32和float64其中之一;
第二个参数filter:相当于CNN中的卷积核,它要求是一个Tensor,具有[filter_height,filter_width,in_channels,out_channels]这样的shape,具体含义是[卷积核的高度,卷积核的宽度,图像通道数,卷积核个数],要求类型与参数input相同,有一个地方需要注意,第三维in_channels,就是参数input的第四维;
第三个参数strides:卷积时在图像每一维的步长,这是一个一维的向量,长度4;
第四个参数padding:string类型的量,只能是"SAME","VALID"其中之一,这个值决定了不同的卷积方式;
第五个参数:use_cudnn_on_gpu:bool类型,是否使用cudnn加速,默认为true。
结果返回一个Tensor,这个输出。
接下来,建一个变量X列表,并根据声学特征建立一个loss函数。新建X列表就是初始一个列表变量(也可认为是建立一个Tensorflow的张量), 它的数据代表着新生成融合语音的数据。只不过初始化时,值为空,要通过机器学习来修改里面的数据,最终逼近真正合成语音的数值。
其中,所述loss函数的公式如下:
l total(a,x,p)=α*l style(a,x)+β*l content(p,x)
其中,l total表示全部差值;l style表示风格语音差值;l content表示内容语音差值;α表示风格语音参数;β表示内容语音参数;a表示风格语音特征值;p表示内容语音特征值;x表示变量特征值。
当x的值达到某一个值时,此时,获取的l total为最小(loss函数L,不一定要等于0,也可以为0,只要其在变小并且有收敛于某一值即可),x的值约等于风格语音特征值,以及约等于内容语音特征值,其中,a和p可以看做为提取的特征值。
根据获取的l total为最小值时,确定X的值,从而确定融合语音的数据。
其中,所述通过Tensorflow的优化器对所述loss函数进行迭代优化的步骤包括:
通过改变loss函数的变量x,获取l total值;
根据获取的l total的最小值,确定loss函数的变量x值;
根据确定的loss函数的变量x值,确定内容语音特征值和风格语音特征值,进而确定待融合的内容语音数据和风格语音数据。
通过Tensorflow中的优化器对loss函数的行数进行迭代优化,使用tf.contrib.optScipyOptimizerInterface方法,具体的优化器是:L-BFGS-B。
简单说,就是改变变量X列表里面数值,同时使上面的损失函数loss的差值达到最小。
其中,tf.contrib.optScipyOptimizerInterface这个接口提供了实现,只要在入参中指定method=‘L-BFGS-B’,Tensorflow就会直接调用,具体的算法内 容是现有技术,在此不再做详述。
其中,将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换。此过程是“将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图”的过程的逆操作,将获取的待融合的内容语音数据和风格语音数据,将获取的语音的频域转换成时域,最终由时域来重新生成语音。
需要说明的是,对信号进行时域分析时,有时一些信号的时域参数相同,但并不能说明信号就完全相同。比如具有相同函数结构的两个信号可能并不相同,因为信号不仅随时间变化,还与频率、相位等信息有关,这就需要进一步分析信号的频率结构,并在频率域中对信号进行描述。
动态信号从时间域变换到频率域主要通过傅立叶级数和傅立叶变换实现。周期信号靠傅立叶级数,非周期信号靠傅立叶变换。很简单时域分析的函数是参数是t,也就是y=f(t),频域分析时,参数是w,也就是y=F(w)两者之间可以互相转化。时域函数通过傅立叶或者拉普拉斯变换就变成了频域函数。
傅里叶变换可以将一个时域信号转换成在不同频率下对应的振幅及相位,其频谱就是时域信号在频域下的表现,而反傅里叶变换可以将频谱再转换回时域的信号。
上述实施例提出的电子装置1,通过Tensorflow的过滤器模板提取内容语音和风格语音的声学特征,并创建loss函数,通过Tensorflow的优化器对所述loss函数进行迭代优化,确定待融合的内容语音数据和风格语音数据,通过librosa将待融合的内容语音数据和风格语音数据进行融合,从而实现将不同风格的语音融合在一起,为说话声自动增加背景音乐、智能创造新音乐,从而为用户提供更多方便和更好地体验。
在其他实施例中,基于Tensorflow的语音融合程序10还可以被分割为一个或者多个模块,一个或者多个模块被存储于存储器11中,并由处理器12执行,以完成本申请。本申请所称的模块是指能够完成特定功能的一系列计算机程序指令段。参照图2所示,为图1中基于Tensorflow的语音融合程序10较佳实施例的程序模块图。所述基于Tensorflow的语音融合程序10可以被分割为:频谱图获取模块110、声学特征获取模块120、loss函数创建模块130、待融合语音数据获取模块140、ISTFT等变换模块150和语音融合模块160。 所述模块110-160所实现的功能或操作步骤均与上文类似,此处不再详述,示例性地,例如其中:
频谱图获取模块110,用于将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
声学特征获取模块120,用于通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
loss函数创建模块130,用于根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
待融合语音数据获取模块140,用于通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
ISTFT等变换模块150,用于将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
语音融合模块160,用于通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
优选地,基于Tensorflow的语音融合程序10还包括语音加载模块。其中,所述语音加载模块,用于通过librosa对内容语音和风格语音进行加载处理;将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
此外,本申请还提供一种基于Tensorflow的语音融合方法。参照图3所示,为本申请基于Tensorflow的语音融合方法较佳实施例的流程图。该方法可以由一个装置执行,该装置可以由软件和/或硬件实现。
在本实施例中,基于Tensorflow的语音融合方法,包括:步骤S10-步骤S60。
步骤S10:将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
步骤S20:通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
步骤S30:根据所述内容语音的声学特征和所述风格语音的声学特征创建 loss函数;
步骤S40:通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
步骤S50:将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
步骤S60:通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
在本申请中在步骤S10之前还包括以下步骤:
通过librosa对内容语音和风格语音进行加载处理;
将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
其中,librosa是一个用于音频、音乐分析、处理的python工具包,一些常见的时频处理、特征提取、绘制声音图形等功能应有尽有,功能十分强大。
加载两条语音的目的是想明确所操作的语音是哪个,即想要融合的内容语音和风格语音各是什么。
语音本身是wav格式的文件,加载是需要把其中wav格式转化为的数据(float浮点数据)放到计算机内存中,以便后续的步骤。
在步骤S10中,将获取的内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图。其中,STFT(短时叶变换)是和傅里叶变换相关的一种数学变换,用以确定时变信号其局部区域正弦波的频率与相位。声音频谱图就是使用stft绘制而成的,其实质就是stft的能量,也就是模值的平方。
在本申请的实施例中,调用librosa的stft函数实现浮点数据到频谱图的转换。即:通过调用librosa的stft函数将内容语音和风格语音由浮点数据转化为内容语音频谱图和风格语音频谱图。
在步骤S20中,通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征。即:新建一个过滤器模板,分别捕获出内容语音和风格语音的声学特征。
过滤器模板其实是对步骤S10得到的频谱做特征提取,采用的方式是用卷积神经网络的tf.nn.conv2d方法,其中卷积核是自定义(如:随机生成一定 维度的数组乘以一个系数),就像在更高纬度抽取一些数值来代表原来更大、更多信息的语音。内容语音和风格语音特征当前抽取还不是非常准确,但可以近似的生成融合后的语音,即融合后的新语音有分别来自原来内容语音、风格语音的内容。
具体地,tf.nn.conv2d是Tensorflow里面实现卷积的函数,这是搭建卷积神经网络比较核心的一个方法。
tf.nn.conv2d(input,filter,strides,padding,use_cudnn_on_gpu=None,name=None)
除去name参数用以指定该操作的name,一共五个参数:
第一个参数input:指需要做卷积的输入图像,它要求是一个Tensor,具有[batch,in_height,in_width,in_channels]这样的shape,具体含义是[训练时一个batch的图片数量,图片高度,图片宽度,图像通道数],注意这是一个4维的Tensor,要求类型为float32和float64其中之一;
第二个参数filter:相当于CNN中的卷积核,它要求是一个Tensor,具有[filter_height,filter_width,in_channels,out_channels]这样的shape,具体含义是[卷积核的高度,卷积核的宽度,图像通道数,卷积核个数],要求类型与参数input相同,有一个地方需要注意,第三维in_channels,就是参数input的第四维;
第三个参数strides:卷积时在图像每一维的步长,这是一个一维的向量,长度4;
第四个参数padding:string类型的量,只能是"SAME","VALID"其中之一,这个值决定了不同的卷积方式;
第五个参数:use_cudnn_on_gpu:bool类型,是否使用cudnn加速,默认为true。
结果返回一个Tensor,这个输出。
在步骤S30中,根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数接下来。
在本申请的实施例中,建一个变量X列表,并根据声学特征建立一个loss函数。新建X列表就是初始一个列表变量(也可认为是建立一个tensorflow的张量),它的数据代表着新生成融合语音的数据。只不过初始化时,值为空, 要通过机器学习来修改里面的数据,最终逼近真正合成语音的数值。
其中,所述loss函数的公式如下:
l total(a,x,p)=α*l style(a,x)+β*l content(p,x)
其中,l total表示全部差值;l style表示风格语音差值;l content表示内容语音差值;α表示风格语音参数;β表示内容语音参数;a表示风格语音特征值;p表示内容语音特征值;x表示变量特征值。
当x的值达到某一个值时,此时,获取的l total为最小(loss函数L,不一定要等于0,也可以为0,只要其在变小并且有收敛于某一值即可),x的值约等于风格语音特征值,以及约等于内容语音特征值,其中,a和p可以看做为提取的特征值。
根据获取的l total为最小值时,确定X的值,从而确定融合语音的数据。
步骤S40:通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据。
在本申请的实施例中,所述通过Tensorfow的优化器对所述loss函数进行迭代优化的步骤包括:
通过改变loss函数的变量x,获取l total值;
根据获取的l total的最小值,确定loss函数的变量x值;
根据确定的loss函数的变量x值,确定内容语音特征值和风格语音特征值,进而确定待融合的内容语音数据和风格语音数据。
通过Tensorflow中的优化器对loss函数行数进行迭代优化,使用tf.contrib.optScipyOptimizerInterface方法,具体的优化器是:L-BFGS-B。
简单说,就是改变变量X列表里面数值,同时使上面的损失函数loss达到最小。
其中,tf.contrib.optScipyOptimizerInterface这个接口提供了实现,只要在 入参中指定method=‘L-BFGS-B’,tensorflow就会直接调用,具体的算法内容是现有技术,在此不再做详述。
步骤S50:将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换。
其中,在本申请的实施例中将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换。此过程是步骤S10的过程的逆操作,将获取的待融合的内容语音数据和风格语音数据,将获取的语音的频域转换成时域,最终由时域来重新生成语音。
需要说明的是,对信号进行时域分析时,有时一些信号的时域参数相同,但并不能说明信号就完全相同。比如具有相同函数结构的两个信号可能并不相同,因为信号不仅随时间变化,还与频率、相位等信息有关,这就需要进一步分析信号的频率结构,并在频率域中对信号进行描述。
动态信号从时间域变换到频率域主要通过傅立叶级数和傅立叶变换实现。周期信号靠傅立叶级数,非周期信号靠傅立叶变换。很简单时域分析的函数是参数是t,也就是y=f(t),频域分析时,参数是w,也就是y=F(w)两者之间可以互相转化。时域函数通过傅立叶或者拉普拉斯变换就变成了频域函数。
傅里叶变换可以将一个时域信号转换成在不同频率下对应的振幅及相位,其频谱就是时域信号在频域下的表现,而反傅里叶变换可以将频谱再转换回时域的信号。
上述实施例提出的基于Tensorflow的语音融合方法,通过Tensorflow的过滤器模板提取内容语音和风格语音的声学特征,并创建loss函数,通过Tensorflow的优化器对所述loss函数的进行迭代优化,确定待融合的内容语音数据和风格语音数据,通过librosa将待融合的内容语音数据和风格语音数据进行融合,从而实现将不同风格的语音融合在一起,为说话声自动增加背景音乐、智能创造新音乐,从而为用户提供更多方便和更好地体验。
此外,本申请实施例还提出一种计算机可读存储介质,所述计算机可读存储介质中包括基于Tensorflow的语音融合程序,所述基于Tensorflow的语音融合程序被处理器执行时实现如下操作:
将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
优选地,在将内容语音数据和风格语音数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图的步骤之前,还包括如下步骤:
通过librosa对内容语音和风格语音进行加载处理;
将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
优选地,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,其中,
所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
优选地,所述loss函数的公式如下:
l total(a,x,p)=α*l style(a,x)+β*l content(p,x)
其中,l total表示全部差值;l style表示风格语音差值;
l content表示内容语音差值;α表示风格语音参数;
β表示内容语音参数;a表示风格语音特征值;
p表示内容语音特征值;x表示变量特征值。
优选地,所述通过TensorFlow的优化器对所述loss函数进行迭代优化的步骤包括:
通过改变loss函数的变量x,获取l total值;
根据获取的l total的最小值,确定loss函数的变量x值;
根据确定的loss函数的变量x值,确定内容语音特征值和风格语音特征值,进而确定待融合的内容语音数据和风格语音数据。
优选地,所述Tensorflow的优化器为L-BFGS-B算法。
本申请之计算机可读存储介质的具体实施方式与上述基于Tensorflow的语音融合方法、电子装置的具体实施方式大致相同,在此不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、装置、物品或者方法不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、装置、物品或者方法所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、装置、物品或者方法中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种基于Tensorflow的语音融合方法,应用于电子装置,其特征在于,所述方法包括:
    将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
    通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
    根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
    通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
    将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
    通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
  2. 根据权利要求1所述的基于Tensorflow的语音融合方法,其特征在于,在将内容语音数据和风格语音数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图的步骤之前,还包括如下步骤:
    通过librosa对内容语音和风格语音进行加载处理;
    将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
  3. 根据权利要求1所述的基于Tensorflow的语音融合方法,其特征在于,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
    所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,其中,
    所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
  4. 根据权利要求2所述的基于Tensorflow的语音融合方法,其特征在于,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
    所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音 频谱图和所述风格语音频谱图进行特征提取,其中,
    所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
  5. 根据权利要求1所述的基于Tensorflow的语音融合方法,其特征在于,所述loss函数的公式如下:
    l total(a,x,p)=α*l style(a,x)+β*l content(p,x)
    其中,l total表示全部差值;l style表示风格语音差值;
    l content表示内容语音差值;α表示风格语音参数;
    β表示内容语音参数;a表示风格语音特征值;
    p表示内容语音特征值;x表示变量特征值。
  6. 根据权利要求5所述的基于Tensorflow的语音融合方法,其特征在于,所述通过Tensorflow的优化器对所述loss函数进行迭代优化的步骤包括:
    通过改变loss函数的变量x,获取l total值;
    根据获取的l total的最小值,确定loss函数的变量x值;
    根据确定的loss函数的变量x值,确定内容语音特征值和风格语音特征值,进而确定待融合的内容语音数据和风格语音数据。
  7. 根据权利要求1所述的基于Tensorflow的语音融合方法,其特征在于,所述Tensorflow的优化器为L-BFGS-B算法。
  8. 一种电子装置,其特征在于,该电子装置包括:存储器、处理器,所述存储器中包括基于Tensorflow的语音融合程序,所述基于Tensorflow的语音融合程序被所述处理器执行时实现如下步骤:
    将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
    通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
    根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
    通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函数的差值最小时,确定待融合的内容语音数据和风格语音数据;
    将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
    通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
  9. 根据权利要求8所述的电子装置,其特征在于,在将内容语音数据和风格语音数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图的步骤之前,还包括如下步骤:
    通过librosa对内容语音和风格语音进行加载处理;
    将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
  10. 根据权利要求8所述的电子装置,其特征在于,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
    所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,其中,
    所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
  11. 根据权利要求9所述的电子装置,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
    所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,其中,
    所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
  12. 根据权利要求8所述的电子装置,其特征在于,所述loss函数的公 式如下:
    l total(a,x,p)=α*l style(a,x)+β*l content(p,x)
    其中,l total表示全部差值;l style表示风格语音差值;
    l content表示内容语音差值;α表示风格语音参数;
    β表示内容语音参数;a表示风格语音特征值;
    p表示内容语音特征值;x表示变量特征值。
  13. 根据权利要求12所述的电子装置,其特征在于,所述通过TensorFlow的优化器对所述loss函数进行迭代优化的步骤包括:
    通过改变loss函数的变量x,获取l total值;
    根据获取的l total的最小值,确定loss函数的变量x值;
    根据确定的loss函数的变量x值,确定内容语音特征值和风格语音特征值,进而确定待融合的内容语音数据和风格语音数据。
  14. 一种计算机非易失性可读存储介质,其特征在于,所述计算机非易失性可读存储介质中包括基于Tensorflow的语音融合程序,所述基于Tensorflow的语音融合程序被处理器执行时,实现如下步骤:
    将内容语音浮点数据和风格语音浮点数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图;
    通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,获取内容语音的声学特征和风格语音的声学特征;
    根据所述内容语音的声学特征和所述风格语音的声学特征创建loss函数;
    通过Tensorflow的优化器对所述loss函数进行迭代优化,当所述loss函 数的差值最小时,确定待融合的内容语音数据和风格语音数据;
    将所述待融合的内容语音数据和风格语音数据进行ISTFT等变换;
    通过librosa将ISTFT等变换处理后的待融合的内容语音数据和风格语音数据合成MP3格式的语音。
  15. 根据权利要求14所述的计算机非易失性可读存储介质,其特征在于,在将内容语音数据和风格语音数据通过STFT等变化转换成内容语音频谱图和风格语音频谱图的步骤之前,还包括如下步骤:
    通过librosa对内容语音和风格语音进行加载处理;
    将所述内容语音转换为所述内容语音浮点数据,将所述风格语音转换为所述风格语音浮点数据。
  16. 根据权利要求14所述的计算机非易失性可读存储介质,其特征在于,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
    所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,其中,
    所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
  17. 根据权利要求15所述的计算机非易失性可读存储介质,其特征在于,所述通过过滤器模板分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取的步骤包括:
    所述过滤器模板通过卷积神经网络的tf.nn.conv2d分别对所述内容语音频谱图和所述风格语音频谱图进行特征提取,其中,
    所述卷积神经网络的tf.nn.conv2d为基于Tensorflow实现的卷积神经网络的函数。
  18. 根据权利要求14所述的计算机非易失性可读存储介质,其特征在于,所述loss函数的公式如下:
    l total(a,x,p)=α*l style(a,x)+β*l content(p,x)
    其中,l total表示全部差值;l style表示风格语音差值;
    l content表示内容语音差值;α表示风格语音参数;
    β表示内容语音参数;a表示风格语音特征值;
    p表示内容语音特征值;x表示变量特征值。
  19. 根据权利要求18所述的计算机非易失性可读存储介质,其特征在于,所述通过Tensorflow的优化器对所述loss函数进行迭代优化的步骤包括:
    通过改变loss函数的变量x,获取l total值;
    根据获取的l total的最小值,确定loss函数的变量x值;
    根据确定的loss函数的变量x值,确定内容语音特征值和风格语音特征值,进而确定待融合的内容语音数据和风格语音数据。
  20. 根据权利要求14所述的计算机非易失性可读存储介质,其特征在于,所述Tensorflow的优化器为L-BFGS-B算法。
PCT/CN2019/103573 2019-06-27 2019-08-30 基于Tensorflow的语音融合方法、电子装置及存储介质 Ceased WO2020258503A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910566906.2A CN110299148B (zh) 2019-06-27 2019-06-27 基于Tensorflow的语音融合方法、电子装置及存储介质
CN201910566906.2 2019-06-27

Publications (1)

Publication Number Publication Date
WO2020258503A1 true WO2020258503A1 (zh) 2020-12-30

Family

ID=68029015

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/103573 Ceased WO2020258503A1 (zh) 2019-06-27 2019-08-30 基于Tensorflow的语音融合方法、电子装置及存储介质

Country Status (2)

Country Link
CN (1) CN110299148B (zh)
WO (1) WO2020258503A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112259086A (zh) * 2020-10-15 2021-01-22 杭州电子科技大学 一种基于语谱图合成的语音转换方法
CN114299969B (zh) * 2021-08-19 2024-06-11 腾讯科技(深圳)有限公司 音频合成方法、装置、设备及介质

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106847294A (zh) * 2017-01-17 2017-06-13 百度在线网络技术(北京)有限公司 基于人工智能的音频处理方法和装置

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101116236B1 (ko) * 2009-07-29 2012-03-09 한국과학기술원 Wtm을 기반으로 손실함수와 최대마진기법을 통한 음성 감정 인식 모델 구축 방법.
CN109524020B (zh) * 2018-11-20 2023-07-04 上海海事大学 一种语音增强处理方法

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106847294A (zh) * 2017-01-17 2017-06-13 百度在线网络技术(北京)有限公司 基于人工智能的音频处理方法和装置

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
ANONYMOUS AUTHORS PAPER UNDER DOUBLE-BLIND REVIEW: ""STYLE" TRANSFER FOR MUSICAL AUDIO USING MULTIPLE TIME-FREQUENCY REPRESENTATIONS", UNDER REVIEW AS A CONFERENCE PAPER AT ICLR 2018, 31 December 2018 (2018-12-31), XP055770026, DOI: 20200319202605X *
BARIS DEMIRDELEN: "Neural Style Transfer on Audio", MSC ARTIFICIAL INTELLIGENCE MASTER THESIS OF UNIVERSITY OF AMSTERDAM, 31 August 2017 (2017-08-31), DOI: 20200319201611 *
GRINSTEIN, E. ET AL.: "Audio Style Transfer", 2018 IEEE INTERNATIONAL CONFERENCE ON ACOUSTICS, SPEECH AND SIGNAL PROCESSING (ICASSP), 20 April 2018 (2018-04-20), XP081323360, ISSN: 2379-190X, DOI: 20200319202842A *
TOMCZAK, M. ET AL.: "Audio Style Transfer With Rhythmic Constraints", PROCEEDINGS OF THE 21ST INTERNATIONAL CONFERENCE ON DIGITAL AUDIO EFFECTS (DAFX-18), 8 September 2018 (2018-09-08), XP055770025, DOI: 20200319202023X *

Also Published As

Publication number Publication date
CN110299148A (zh) 2019-10-01
CN110299148B (zh) 2024-05-28

Similar Documents

Publication Publication Date Title
CN110223695B (zh) 一种任务创建方法及移动终端
CN106570106A (zh) 一种输入过程中将语音信息转化为表情的方法和装置
JP6019604B2 (ja) 音声認識装置、音声認識方法、及びプログラム
CN104142909A (zh) 一种汉字注音方法及装置
CN104361896B (zh) 语音质量评价设备、方法和系统
CN110334332A (zh) 一种演示文稿生成方法、装置、存储介质及电子设备
CN105489221A (zh) 一种语音识别方法及装置
WO2020238045A1 (zh) 智能语音识别方法、装置及计算机可读存储介质
CN109326284B (zh) 语音搜索的方法、装置和存储介质
AU2017216520A1 (en) Common data repository for improving transactional efficiencies of user interactions with a computing device
WO2023015841A1 (zh) 基于人工智能的 sql 语句生成方法、装置、设备及存储介质
CN108491326A (zh) 测试行为重组方法、装置及存储介质
CN111462736B (zh) 基于语音的图像生成方法、装置和电子设备
WO2020258503A1 (zh) 基于Tensorflow的语音融合方法、电子装置及存储介质
CN111028828A (zh) 一种基于画屏的语音交互方法、画屏及存储介质
CN118502857A (zh) 用户界面的交互处理方法、装置、设备、介质及程序产品
CN111898363B (zh) 文本长难句的压缩方法、装置、计算机设备及存储介质
CN113741864B (zh) 基于自然语言处理的语义化服务接口自动设计方法与系统
CN110110770A (zh) 基于神经网络的服装图片导购文字生成方法及装置
CN106873798B (zh) 用于输出信息的方法和装置
CN114047900A (zh) 业务处理方法、装置、电子设备及计算机可读存储介质
CN113703638B (zh) 数据管理页面处理方法、装置、电子设备及存储介质
TW201506685A (zh) 以語音辨識來選擇控制客體的裝置及方法
CN108231074A (zh) 一种数据处理方法、语音助手设备及计算机可读存储介质
CN112908307A (zh) 一种音频特征提取方法、系统、设备及介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19935649

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19935649

Country of ref document: EP

Kind code of ref document: A1