-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from sp-nitech/aperiodicity
Add ap command
- Loading branch information
Showing
31 changed files
with
2,335 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. _ap: | ||
|
||
ap | ||
== | ||
|
||
.. doxygenfile:: ap.cc | ||
|
||
.. doxygenclass:: sptk::AperiodicityExtraction | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// ------------------------------------------------------------------------ // | ||
// Copyright 2021 SPTK Working Group // | ||
// // | ||
// Licensed under the Apache License, Version 2.0 (the "License"); // | ||
// you may not use this file except in compliance with the License. // | ||
// You may obtain a copy of the License at // | ||
// // | ||
// http://www.apache.org/licenses/LICENSE-2.0 // | ||
// // | ||
// Unless required by applicable law or agreed to in writing, software // | ||
// distributed under the License is distributed on an "AS IS" BASIS, // | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // | ||
// See the License for the specific language governing permissions and // | ||
// limitations under the License. // | ||
// ------------------------------------------------------------------------ // | ||
|
||
#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_H_ | ||
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_H_ | ||
|
||
#include <vector> // std::vector | ||
|
||
#include "SPTK/analysis/aperiodicity_extraction_interface.h" | ||
#include "SPTK/utils/sptk_utils.h" | ||
|
||
namespace sptk { | ||
|
||
/** | ||
* Extract aperiodicity from waveform. | ||
* | ||
* The input is whole audio waveform and the output is the sequence of the | ||
* aperiodicity measure. The implemented algorithms of the extraction are | ||
* TANDEM-STRAIGHT and D4C. | ||
* | ||
* [1] H. Kawahara et al., "Simplification and extension of non-periodic | ||
* excitation source representations for high-quality speech manipulation | ||
* systems," Proc. of Interspeech, pp. 38-41, 2010. | ||
* | ||
* [2] M. Morise, "D4C, a band-aperiodicity estimator for high-quality | ||
* speech synthesis," Proc. of Speech Communication, vol. 84, | ||
* pp. 57-65, 2016. | ||
*/ | ||
class AperiodicityExtraction { | ||
public: | ||
/** | ||
* Aperiodicity extraction algorithms. | ||
*/ | ||
enum Algorithms { kTandem = 0, kWorld, kNumAlgorithms }; | ||
|
||
/** | ||
* @param[in] fft_length FFT length. | ||
* @param[in] frame_shift Frame shift in point. | ||
* @param[in] sampling_rate Sampling rate in Hz. | ||
* @param[in] algorithm Algorithm used for aperiodicity extraction. | ||
*/ | ||
AperiodicityExtraction(int fft_length, int frame_shift, double sampling_rate, | ||
Algorithms algorithm); | ||
|
||
virtual ~AperiodicityExtraction() { | ||
delete aperiodicity_extraction_; | ||
} | ||
|
||
/** | ||
* @return True if this object is valid. | ||
*/ | ||
bool IsValid() const { | ||
return (NULL != aperiodicity_extraction_ && | ||
aperiodicity_extraction_->IsValid()); | ||
} | ||
|
||
/** | ||
* @param[in] waveform Waveform. | ||
* @param[in] f0 Fundamental frequency in Hz. | ||
* @param[out] aperiodicity Aperiodicity measure. | ||
* @return True on success, false on failure. | ||
*/ | ||
bool Run(const std::vector<double>& waveform, const std::vector<double>& f0, | ||
std::vector<std::vector<double> >* aperiodicity) const; | ||
|
||
private: | ||
AperiodicityExtractionInterface* aperiodicity_extraction_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AperiodicityExtraction); | ||
}; | ||
|
||
} // namespace sptk | ||
|
||
#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// ------------------------------------------------------------------------ // | ||
// Copyright 2021 SPTK Working Group // | ||
// // | ||
// Licensed under the Apache License, Version 2.0 (the "License"); // | ||
// you may not use this file except in compliance with the License. // | ||
// You may obtain a copy of the License at // | ||
// // | ||
// http://www.apache.org/licenses/LICENSE-2.0 // | ||
// // | ||
// Unless required by applicable law or agreed to in writing, software // | ||
// distributed under the License is distributed on an "AS IS" BASIS, // | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // | ||
// See the License for the specific language governing permissions and // | ||
// limitations under the License. // | ||
// ------------------------------------------------------------------------ // | ||
|
||
#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_TANDEM_H_ | ||
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_TANDEM_H_ | ||
|
||
#include <vector> // std::vector | ||
|
||
#include "SPTK/analysis/aperiodicity_extraction_interface.h" | ||
#include "SPTK/utils/sptk_utils.h" | ||
|
||
namespace sptk { | ||
|
||
/** | ||
* Extract aperiodicity based on TANDEM-STRAIGHT. | ||
*/ | ||
class AperiodicityExtractionByTandem : public AperiodicityExtractionInterface { | ||
public: | ||
/** | ||
* @param[in] fft_length FFT length. | ||
* @param[in] frame_shift Frame shift in point. | ||
* @param[in] sampling_rate Sampling rate in Hz. | ||
*/ | ||
AperiodicityExtractionByTandem(int fft_length, int frame_shift, | ||
double sampling_rate); | ||
|
||
virtual ~AperiodicityExtractionByTandem() { | ||
} | ||
|
||
/** | ||
* @return FFT length. | ||
*/ | ||
int GetFftLength() const { | ||
return fft_length_; | ||
} | ||
|
||
/** | ||
* @return Frame shift. | ||
*/ | ||
virtual int GetFrameShift() const { | ||
return frame_shift_; | ||
} | ||
|
||
/** | ||
* @return Sampling rate. | ||
*/ | ||
double GetSamplingRate() const { | ||
return sampling_rate_; | ||
} | ||
|
||
/** | ||
* @return True if this object is valid. | ||
*/ | ||
virtual bool IsValid() const { | ||
return is_valid_; | ||
} | ||
|
||
/** | ||
* @param[in] waveform Waveform. | ||
* @param[in] f0 Fundamental frequency in Hz. | ||
* @param[out] aperiodicity Aperiodicity measure. | ||
* @return True on success, false on failure. | ||
*/ | ||
virtual bool Run(const std::vector<double>& waveform, | ||
const std::vector<double>& f0, | ||
std::vector<std::vector<double> >* aperiodicity) const; | ||
|
||
private: | ||
const int fft_length_; | ||
const int frame_shift_; | ||
const double sampling_rate_; | ||
|
||
bool is_valid_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AperiodicityExtractionByTandem); | ||
}; | ||
|
||
} // namespace sptk | ||
|
||
#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_TANDEM_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// ------------------------------------------------------------------------ // | ||
// Copyright 2021 SPTK Working Group // | ||
// // | ||
// Licensed under the Apache License, Version 2.0 (the "License"); // | ||
// you may not use this file except in compliance with the License. // | ||
// You may obtain a copy of the License at // | ||
// // | ||
// http://www.apache.org/licenses/LICENSE-2.0 // | ||
// // | ||
// Unless required by applicable law or agreed to in writing, software // | ||
// distributed under the License is distributed on an "AS IS" BASIS, // | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // | ||
// See the License for the specific language governing permissions and // | ||
// limitations under the License. // | ||
// ------------------------------------------------------------------------ // | ||
|
||
#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_WORLD_H_ | ||
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_WORLD_H_ | ||
|
||
#include <vector> // std::vector | ||
|
||
#include "SPTK/analysis/aperiodicity_extraction_interface.h" | ||
#include "SPTK/utils/sptk_utils.h" | ||
|
||
namespace sptk { | ||
|
||
/** | ||
* Extract aperiodicity based on WORLD (D4C). | ||
*/ | ||
class AperiodicityExtractionByWorld : public AperiodicityExtractionInterface { | ||
public: | ||
/** | ||
* @param[in] fft_length FFT length. | ||
* @param[in] frame_shift Frame shift in point. | ||
* @param[in] sampling_rate Sampling rate in Hz. | ||
*/ | ||
AperiodicityExtractionByWorld(int fft_length, int frame_shift, | ||
double sampling_rate); | ||
|
||
virtual ~AperiodicityExtractionByWorld() { | ||
} | ||
|
||
/** | ||
* @return FFT length. | ||
*/ | ||
int GetFftLength() const { | ||
return fft_length_; | ||
} | ||
|
||
/** | ||
* @return Frame shift. | ||
*/ | ||
virtual int GetFrameShift() const { | ||
return frame_shift_; | ||
} | ||
|
||
/** | ||
* @return Sampling rate. | ||
*/ | ||
double GetSamplingRate() const { | ||
return sampling_rate_; | ||
} | ||
|
||
/** | ||
* @return True if this object is valid. | ||
*/ | ||
virtual bool IsValid() const { | ||
return is_valid_; | ||
} | ||
|
||
/** | ||
* @param[in] waveform Waveform. | ||
* @param[in] f0 Fundamental frequency in Hz. | ||
* @param[out] aperiodicity Aperiodicity measure. | ||
* @return True on success, false on failure. | ||
*/ | ||
virtual bool Run(const std::vector<double>& waveform, | ||
const std::vector<double>& f0, | ||
std::vector<std::vector<double> >* aperiodicity) const; | ||
|
||
private: | ||
const int fft_length_; | ||
const int frame_shift_; | ||
const double sampling_rate_; | ||
|
||
bool is_valid_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AperiodicityExtractionByWorld); | ||
}; | ||
|
||
} // namespace sptk | ||
|
||
#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_BY_WORLD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// ------------------------------------------------------------------------ // | ||
// Copyright 2021 SPTK Working Group // | ||
// // | ||
// Licensed under the Apache License, Version 2.0 (the "License"); // | ||
// you may not use this file except in compliance with the License. // | ||
// You may obtain a copy of the License at // | ||
// // | ||
// http://www.apache.org/licenses/LICENSE-2.0 // | ||
// // | ||
// Unless required by applicable law or agreed to in writing, software // | ||
// distributed under the License is distributed on an "AS IS" BASIS, // | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // | ||
// See the License for the specific language governing permissions and // | ||
// limitations under the License. // | ||
// ------------------------------------------------------------------------ // | ||
|
||
#ifndef SPTK_ANALYSIS_APERIODICITY_EXTRACTION_INTERFACE_H_ | ||
#define SPTK_ANALYSIS_APERIODICITY_EXTRACTION_INTERFACE_H_ | ||
|
||
#include <vector> // std::vector | ||
|
||
namespace sptk { | ||
|
||
/** | ||
* An interface of aperiodicity extraction. | ||
*/ | ||
class AperiodicityExtractionInterface { | ||
public: | ||
virtual ~AperiodicityExtractionInterface() { | ||
} | ||
|
||
/** | ||
* @return Frame shift. | ||
*/ | ||
virtual int GetFrameShift() const = 0; | ||
|
||
/** | ||
* @return True if this object is valid. | ||
*/ | ||
virtual bool IsValid() const = 0; | ||
|
||
/** | ||
* @param[in] waveform Waveform. | ||
* @param[in] f0 Fundamental frequency in Hz. | ||
* @param[out] aperiodicity Aperiodicity measure. | ||
* @return True on success, false on failure. | ||
*/ | ||
virtual bool Run(const std::vector<double>& waveform, | ||
const std::vector<double>& f0, | ||
std::vector<std::vector<double> >* aperiodicity) const = 0; | ||
}; | ||
|
||
} // namespace sptk | ||
|
||
#endif // SPTK_ANALYSIS_APERIODICITY_EXTRACTION_INTERFACE_H_ |
Oops, something went wrong.