Skip to main content

JAX Implementation FCPE

Project description

FCPE jax version

This version is working perfectly fine. 😀

Original https://github.com/CNChTu/FCPE

Example

import jax_fcpe
import jax.numpy as jnp

a = jnp.ones((16000))
f0 = jax_fcpe.get_f0(a,16000)
print(f0)

Advanced Usage

WIN_SIZE = 1024
HOP_SIZE = 160
N_FFT = 1024
NUM_MELS = 128
f0_min = 80.
f0_max = 880.
mel_basis = librosa_mel_fn(sr=16000, n_fft=N_FFT, n_mels=NUM_MELS, fmin=0, fmax=8000)
mel_basis = jnp.asarray(mel_basis,dtype=jnp.float32)

def get_f0(wav,model,params):
    wav = jnp.asarray(wav)
    window = jnp.hanning(WIN_SIZE)
    pad_size = (WIN_SIZE-HOP_SIZE)//2
    wav = jnp.pad(wav, ((0,0),(pad_size, pad_size)),mode="reflect")
    spec = audax.core.stft.stft(wav,N_FFT,HOP_SIZE,WIN_SIZE,window,onesided=True,center=False)
    spec = jnp.sqrt(spec.real**2 + spec.imag**2 + (1e-9))
    spec = spec.transpose(0,2,1)
    mel = jnp.matmul(mel_basis, spec)
    mel = jnp.log(jnp.clip(mel, min=1e-5) * 1)
    mel = mel.transpose(0,2,1)

    def model_predict(mel):
        f0 = model.apply(params,mel,threshold=0.006,method=model.infer)
        uv = (f0 < f0_min).astype(jnp.float32)
        f0 = f0 * (1 - uv)
        return f0
    return model_predict(mel).squeeze(-1)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jax_fcpe-0.0.6.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jax_fcpe-0.0.6-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file jax_fcpe-0.0.6.tar.gz.

File metadata

  • Download URL: jax_fcpe-0.0.6.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for jax_fcpe-0.0.6.tar.gz
Algorithm Hash digest
SHA256 3299a0cfbbf686a10f31a4e55102f8834d553d2145fe2670274ca6cff9479945
MD5 351f9ea8be84ecc67a9dcfad886e9f96
BLAKE2b-256 57e621a0963869278618e8d4f38981327fffe858c22e36229a19a3eef038e628

See more details on using hashes here.

File details

Details for the file jax_fcpe-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: jax_fcpe-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for jax_fcpe-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4a2c53baab6623159afb80fa6ab7ea3c0880add5f79695117894b2a9dd683363
MD5 255186d2fc656a2ce108a5f5037474f5
BLAKE2b-256 042a633914c82357a4c3021fdcc72f093286fba735a7506ec8af2cba181e8a5b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page