1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef MINDSPORE_CORE_OPS_AUDIO_SPECTROGRAM_H_ 18 #define MINDSPORE_CORE_OPS_AUDIO_SPECTROGRAM_H_ 19 #include <map> 20 #include <vector> 21 #include <string> 22 #include <memory> 23 #include "ops/primitive_c.h" 24 #include "abstract/abstract_value.h" 25 #include "utils/check_convert_utils.h" 26 27 namespace mindspore { 28 namespace ops { 29 constexpr auto kNameAudioSpectrogram = "AudioSpectrogram"; 30 /// \brief AudioSpectrogram defined AudioSpectrogram operator prototype. 31 class MS_CORE_API AudioSpectrogram : public PrimitiveC { 32 public: 33 /// \brief Constructor. AudioSpectrogram()34 AudioSpectrogram() : PrimitiveC(kNameAudioSpectrogram) {} 35 36 /// \brief Destructor. 37 ~AudioSpectrogram() = default; 38 39 MS_DECLARE_PARENT(AudioSpectrogram, PrimitiveC); 40 41 /// \brief Method to init the op's attributes. 42 /// 43 /// \param[in] window_size Define the size of window. 44 /// \param[in] stride Define the step size of window to move. 45 /// \param[in] mag_square Define a boolean value to indicate the output is the magnitude or the square of magnitude. 46 void Init(const int64_t window_size, const int64_t stride, const bool mag_square); 47 48 /// \brief Method to set window_size attribute. 49 /// 50 /// \param[in] window_size Define the size of window. 51 void set_window_size(const int64_t window_size); 52 53 /// \brief Method to set stride attribute. 54 /// 55 /// \param[in] stride Define the step size of window to move. 56 void set_stride(const int64_t stride); 57 58 /// \brief Method to set mag_square attribute. 59 /// 60 /// \param[in] mag_square Define a boolean to indicate the output is the magnitude or the square of magnitude. 61 void set_mag_square(const bool mag_square); 62 63 /// \brief Method to get window_size attribute. 64 /// 65 /// \return the size of window. 66 int64_t get_window_size() const; 67 68 /// \brief Method to get stride attribute. 69 /// 70 /// \return the step size. 71 int64_t get_stride() const; 72 73 /// \brief Method to get mag_square attribute. 74 /// 75 /// \return a boolean value. 76 bool get_mag_square() const; 77 }; 78 AbstractBasePtr AudioSpectrogramInfer(const abstract::AnalysisEnginePtr &, const PrimitivePtr &primitive, 79 const std::vector<AbstractBasePtr> &input_args); 80 using PrimAudioSpectrogramPtr = std::shared_ptr<AudioSpectrogram>; 81 } // namespace ops 82 } // namespace mindspore 83 84 #endif // MINDSPORE_CORE_OPS_AUDIO_SPECTROGRAM_H_ 85