Skip to main content

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)

Metadata

Release files for jax-fcpe 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jax-fcpe 0.0.6
File Size Uploaded
jax_fcpe-0.0.6.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jax-fcpe 0.0.6
File Interpreter ABI Platform
jax_fcpe-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 23.9 kB

Release files / jax_fcpe-0.0.6.tar.gz

Download URL jax_fcpe-0.0.6.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3299a0cfbbf686a10f31a4e55102f8834d553d2145fe2670274ca6cff9479945
BLAKE2b-256 checksum
How to use checksums
57e621a0963869278618e8d4f38981327fffe858c22e36229a19a3eef038e628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release files / jax_fcpe-0.0.6-py3-none-any.whl

Download URL jax_fcpe-0.0.6-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4a2c53baab6623159afb80fa6ab7ea3c0880add5f79695117894b2a9dd683363
BLAKE2b-256 checksum
How to use checksums
042a633914c82357a4c3021fdcc72f093286fba735a7506ec8af2cba181e8a5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.11

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page