push_dac_to_hub.py 639 Bytes
Newer Older
Yoach Lacombe's avatar
add DAC  
Yoach Lacombe committed
1
import dac
Yoach Lacombe's avatar
Yoach Lacombe committed
2

Yoach Lacombe's avatar
add DAC  
Yoach Lacombe committed
3
4
5
6
# Download a model
model_path = dac.utils.download(model_type="44khz")
model = dac.DAC.load(model_path)

Yoach Lacombe's avatar
Yoach Lacombe committed
7
from parler_tts import DACConfig, DACModel
Yoach Lacombe's avatar
add DAC  
Yoach Lacombe committed
8
9
10
11
12

hf_dac = DACModel(DACConfig())
hf_dac.model.load_state_dict(model.state_dict())

from transformers import AutoConfig, AutoModel
Yoach Lacombe's avatar
Yoach Lacombe committed
13

Yoach Lacombe's avatar
add DAC  
Yoach Lacombe committed
14
15
16
17
18
19
20
21
22
23
AutoConfig.register("dac", DACConfig)
AutoModel.register(DACConfig, DACModel)

hf_dac.push_to_hub("ylacombe/dac_44khZ_8kbps")

# DACConfig.register_for_auto_class()
# DACModel.register_for_auto_class("AutoModel")

from transformers import EncodecFeatureExtractor

Yoach Lacombe's avatar
Yoach Lacombe committed
24
EncodecFeatureExtractor(sampling_rate=44100).push_to_hub("ylacombe/dac_44khZ_8kbps")