Spaces:
Sleeping
Sleeping
Update infer_zipvoice.py
Browse files- infer_zipvoice.py +3 -52
infer_zipvoice.py
CHANGED
|
@@ -1,58 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
# See ../../../../LICENSE for clarification regarding multiple authors
|
| 5 |
-
#
|
| 6 |
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 7 |
-
# you may not use this file except in compliance with the License.
|
| 8 |
-
# You may obtain a copy of the License at
|
| 9 |
-
#
|
| 10 |
-
# http://www.apache.org/licenses/LICENSE-2.0
|
| 11 |
-
#
|
| 12 |
-
# Unless required by applicable law or agreed to in writing, software
|
| 13 |
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 14 |
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 15 |
-
# See the License for the specific language governing permissions and
|
| 16 |
-
# limitations under the License.
|
| 17 |
-
|
| 18 |
-
"""
|
| 19 |
-
This script generates speech with our pre-trained ZipVoice or
|
| 20 |
-
ZipVoice-Distill models. If no local model is specified,
|
| 21 |
-
Required files will be automatically downloaded from HuggingFace.
|
| 22 |
-
|
| 23 |
-
Usage:
|
| 24 |
-
|
| 25 |
-
Note: If you having trouble connecting to HuggingFace,
|
| 26 |
-
try switching endpoint to mirror site:
|
| 27 |
-
export HF_ENDPOINT=https://hf-mirror.com
|
| 28 |
-
|
| 29 |
-
(1) Inference of a single sentence:
|
| 30 |
-
|
| 31 |
-
python3 -m zipvoice.bin.infer_zipvoice \
|
| 32 |
-
--model-name "zipvoice" \
|
| 33 |
-
--prompt-wav prompt.wav \
|
| 34 |
-
--prompt-text "I am a prompt." \
|
| 35 |
-
--text "I am a sentence." \
|
| 36 |
-
--res-wav-path result.wav
|
| 37 |
-
|
| 38 |
-
(2) Inference of a list of sentences:
|
| 39 |
-
|
| 40 |
-
python3 -m zipvoice.bin.infer_zipvoice \
|
| 41 |
-
--model-name "zipvoice" \
|
| 42 |
-
--test-list test.tsv \
|
| 43 |
-
--res-dir results
|
| 44 |
-
|
| 45 |
-
`--model-name` can be `zipvoice` or `zipvoice_distill`,
|
| 46 |
-
which are the models before and after distillation, respectively.
|
| 47 |
-
|
| 48 |
-
Each line of `test.tsv` is in the format of
|
| 49 |
-
`{wav_name}\t{prompt_transcription}\t{prompt_wav}\t{text}`.
|
| 50 |
-
"""
|
| 51 |
-
|
| 52 |
import argparse
|
| 53 |
import datetime as dt
|
| 54 |
import json
|
| 55 |
-
import os
|
| 56 |
from typing import Optional
|
| 57 |
|
| 58 |
import numpy as np
|
|
|
|
| 1 |
+
# Ẩn mọi GPU để tránh PyTorch cố khởi tạo CUDA khi chạy trên Space CPU
|
| 2 |
+
import os
|
| 3 |
+
os.environ.setdefault("CUDA_VISIBLE_DEVICES", "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import argparse
|
| 5 |
import datetime as dt
|
| 6 |
import json
|
|
|
|
| 7 |
from typing import Optional
|
| 8 |
|
| 9 |
import numpy as np
|