File size: 731 Bytes
dd9600d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import torch 
import penn

def pitch_apply(waveform):
    hopsize = .01
    fmin = 30.
    fmax = 1000.
    checkpoint = None
    center = 'half-hop'
    interp_unvoiced_at = .065
    sampling_rate = 16000
    penn_batch_size = 4096
    waveform = torch.Tensor(waveform).unsqueeze(0)
    pitch, periodicity = penn.from_audio(
        waveform.float(),
        sampling_rate,
        hopsize=hopsize,
        fmin=fmin,
        fmax=fmax,
        checkpoint=checkpoint,
        batch_size=penn_batch_size,
        center=center,
        interp_unvoiced_at=interp_unvoiced_at,
        gpu=None
        )     
    
    pitch_mean = pitch.mean().cpu().numpy()
    pitch_std = pitch.std().cpu().numpy()

    return pitch_mean, pitch_std