Librosa:过滤奈奎斯特以外的通带

时间:2019-06-04 04:53:27

标签: python audio librosa

Librosa Python 3.5 在8000Hhz音频样本上出现错误:

  

提取功能错误。滤波器的通带超出了奈奎斯特的范围

以前曾遇到有关Nyquist的其他错误,但已通过手动设置sr和fmin进行了修复,但看起来似乎无法超越。

const SIGN_UP_MUTATION = gql`
  mutation signUp($username: String!, $email: String!, $password: String!) {
    signUp(username: $username, email: $email, password: $password) {
      token
    }
  }
`;

class LoginScreen extends Component {
  constructor(props) {
    super(props);
    this.state = {
      userName: null,
      email: null,
      password: null,
      formErrors: {
        userName: '',
        email: '',
        password: '',
      },
      variables: null,
    };
  }

  _submitForm = e => {
    e.preventDefault();
    const { name, value } = e.target;

    const { userName, email, password } = this.state;

    const { formErrors } = this.state;

    switch (name) {
      case 'userName':
        formErrors.userName = userName.length < 3 && userName.length > 0 ? 'minimum 3 characters required' : '';
        break;
      case 'email':
        formErrors.email = emailRegex.test(email) && email.length > 0 ? '' : 'invalid email address';
        break;
      case 'password':
        formErrors.password = password.length < 6 && password.length > 0 ? 'minimum 3 characters required' : '';
        break;
      default:
        break;
    }

    this.setState({ formErrors, [name]: value }, () => {
      console.log('this.state', this.state);
      this.variables = {
        username: this.state.username,
        email: this.state.email,
        password: this.state.password,
      };
    });
  };

  render() {
    return (
      <View style={styles.container}>
        <Image
          style={styles.logo}
          source={__DEV__ ? require('../assets/images/logo.png') : require('../assets/images/robot-prod.png')}
        />
        <View style={styles.innerContainer}>
          <TextInput
            style={styles.inputBox}
            placeholder="userName"
            name="userName"
            type="userName"
            value={this.state.userName}
            onChangeText={userName => this.setState({ userName })}
            onSubmitEditing={this._submitForm}
          />
          <TextInput
            style={styles.inputBox}
            placeholder="email"
            name="email"
            type="email"
            value={this.state.email}
            onChangeText={email => this.setState({ email })}
            onSubmitEditing={this._submitForm}
          />
          <TextInput
            style={styles.inputBox}
            placeholder="Password"
            name="password"
            type="password"
            onChangeText={password => this.setState({ password })}
            onSubmitEditing={this._submitForm}
            value={this.state.password}
          />
          <View style={styles.inputsContainer}>
            <Mutation mutation={SIGN_UP_MUTATION}>
              {({ data }) => (
                <TouchableOpacity
                  style={styles.buttonContainer}
                  onPress={e => {
                    this._submitForm(e);

                  }}
                >
                  <Text style={styles.buttonText}>Sign Up</Text>
                </TouchableOpacity>
              )}
            </Mutation>
          </View>
        </View>
      </View>
    );
  }

编辑:

tonnetz功能中似乎存在问题。每个docs色度:

stft = np.abs(librosa.stft(X))
mfccs = np.mean(librosa.feature.mfcc(y=X, sr=8000, n_mfcc=40, fmin=60).T,axis=0)
chroma = np.mean(librosa.feature.chroma_stft(S=stft, sr=8000).T,axis=0)
mel = np.mean(librosa.feature.melspectrogram(X, sr=8000, fmin=60).T,axis=0)
contrast = np.mean(librosa.feature.spectral_contrast(S=stft, sr=8000, fmin=60).T,axis=0)
tonnetz = np.mean(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=8000).T,axis=0)
return mfccs, chroma, mel, contrast, tonnetz

cqt色谱图需要其他参数才能与8000Hhz音频一起使用,因此我将需要手动设置色度。不幸的是,这超出了我的Librosa /音频知识,有人为我提供了线索吗?

1 个答案:

答案 0 :(得分:0)

    stft = np.abs(librosa.stft(X))
    mfccs = np.mean(librosa.feature.mfcc(y=X, sr=8000, n_mfcc=40, fmin=30).T,axis=0)
    chroma = np.mean(librosa.feature.chroma_stft(S=stft, sr=8000).T,axis=0)
    mel = np.mean(librosa.feature.melspectrogram(X, sr=8000, fmin=30).T,axis=0)
    contrast = np.mean(librosa.feature.spectral_contrast(S=stft, sr=8000, fmin=30).T,axis=0)
    tonnetz = np.mean(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=sample_rate, chroma=librosa.feature.chroma_cqt(y=X, sr=8000, fmin=30)).T,axis=0)
    return mfccs, chroma, mel, contrast, tonnetz
相关问题