Update README.md
Browse files
README.md
CHANGED
|
@@ -40,8 +40,8 @@ The code is in [DistilCodec](https://github.com/IDEA-Emdoor-Lab/DistilCodec).
|
|
| 40 |
|
| 41 |
from distil_codec import DistilCodec, demo_for_generate_audio_codes
|
| 42 |
|
| 43 |
-
codec_model_config_path='
|
| 44 |
-
codec_ckpt_path = '
|
| 45 |
step=204000
|
| 46 |
|
| 47 |
codec = DistilCodec.from_pretrained(
|
|
@@ -51,8 +51,13 @@ codec = DistilCodec.from_pretrained(
|
|
| 51 |
use_generator=True,
|
| 52 |
is_debug=False).eval()
|
| 53 |
|
| 54 |
-
audio_path = '
|
| 55 |
-
audio_tokens = demo_for_generate_audio_codes(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
print(audio_tokens)
|
| 57 |
|
| 58 |
```
|
|
@@ -62,8 +67,10 @@ print(audio_tokens)
|
|
| 62 |
|
| 63 |
from distil_codec import DistilCodec, demo_for_generate_audio_codes
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
|
|
|
|
|
|
| 67 |
step=204000
|
| 68 |
|
| 69 |
codec = DistilCodec.from_pretrained(
|
|
@@ -73,14 +80,22 @@ codec = DistilCodec.from_pretrained(
|
|
| 73 |
use_generator=True,
|
| 74 |
is_debug=False).eval()
|
| 75 |
|
| 76 |
-
audio_path = '
|
| 77 |
-
audio_tokens = demo_for_generate_audio_codes(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
print(audio_tokens)
|
| 79 |
|
| 80 |
-
#
|
| 81 |
-
gen_audio_save_path = '
|
| 82 |
-
audio_name = '
|
| 83 |
-
y_gen = codec.decode_from_codes(
|
|
|
|
|
|
|
|
|
|
| 84 |
codec.save_wav(
|
| 85 |
audio_gen_batch=y_gen,
|
| 86 |
nhop_lengths=[y_gen.shape[-1]],
|
|
|
|
| 40 |
|
| 41 |
from distil_codec import DistilCodec, demo_for_generate_audio_codes
|
| 42 |
|
| 43 |
+
codec_model_config_path='/path/to/distilcodec/model_config.json'
|
| 44 |
+
codec_ckpt_path = '/path/to/distilcodec_ckpt'
|
| 45 |
step=204000
|
| 46 |
|
| 47 |
codec = DistilCodec.from_pretrained(
|
|
|
|
| 51 |
use_generator=True,
|
| 52 |
is_debug=False).eval()
|
| 53 |
|
| 54 |
+
audio_path = '/path/to/audio_file'
|
| 55 |
+
audio_tokens = demo_for_generate_audio_codes(
|
| 56 |
+
codec,
|
| 57 |
+
audio_path,
|
| 58 |
+
target_sr=24000,
|
| 59 |
+
plus_llm_offset=True # If this parameter set to True, then it will add LLM's vocabulary number to audio token, and DistilCodec's default vocabulary number is from QWen2.5-7B.
|
| 60 |
+
)
|
| 61 |
print(audio_tokens)
|
| 62 |
|
| 63 |
```
|
|
|
|
| 67 |
|
| 68 |
from distil_codec import DistilCodec, demo_for_generate_audio_codes
|
| 69 |
|
| 70 |
+
from distil_codec import DistilCodec, demo_for_generate_audio_codes
|
| 71 |
+
|
| 72 |
+
codec_model_config_path='/path/to/distilcodec/model_config.json'
|
| 73 |
+
codec_ckpt_path = '/path/to/distilcodec_ckpt'
|
| 74 |
step=204000
|
| 75 |
|
| 76 |
codec = DistilCodec.from_pretrained(
|
|
|
|
| 80 |
use_generator=True,
|
| 81 |
is_debug=False).eval()
|
| 82 |
|
| 83 |
+
audio_path = '/path/to/audio_file'
|
| 84 |
+
audio_tokens = demo_for_generate_audio_codes(
|
| 85 |
+
codec,
|
| 86 |
+
audio_path,
|
| 87 |
+
target_sr=24000,
|
| 88 |
+
plus_llm_offset=True # If this parameter set to True, then it will add LLM's vocabulary number to audio token, and DistilCodec's default vocabulary number is from QWen2.5-7B.
|
| 89 |
+
)
|
| 90 |
print(audio_tokens)
|
| 91 |
|
| 92 |
+
# Generated audio save path, the path is f'{gen_audio_save_path}/{audio_name}.wav'
|
| 93 |
+
gen_audio_save_path = '/path/to/audio_save_path'
|
| 94 |
+
audio_name = 'audio_name'
|
| 95 |
+
y_gen = codec.decode_from_codes(
|
| 96 |
+
audio_tokens,
|
| 97 |
+
minus_token_offset=True # if the 'plus_llm_offset' of method demo_for_generate_audio_codes is set to True, then minus_token_offset must be True.
|
| 98 |
+
)
|
| 99 |
codec.save_wav(
|
| 100 |
audio_gen_batch=y_gen,
|
| 101 |
nhop_lengths=[y_gen.shape[-1]],
|