Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added no_mp3_support argument and added a check for ffmpg installation #517

Merged
15 commits merged into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions demo_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import argparse
import torch
import sys

from audioread.exceptions import NoBackendError

if __name__ == '__main__':
## Info & args
Expand All @@ -34,12 +34,22 @@
"If True, audio won't be played.")
parser.add_argument("--seed", type=int, default=None, help=\
"Optional random number seed value to make toolbox deterministic.")
parser.add_argument("--no_mp3_support", action="store_true", help=\
"If True, no mp3 files are allowed.")
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
args = parser.parse_args()
print_args(args, parser)
if not args.no_sound:
import sounddevice as sd

if not args.no_mp3_support:
try:
librosa.load(r"sample\sample_MP3.mp3")
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
except NoBackendError:
print("NoBackendError Exceptions raised please Install ffmpeg or rerun using no_mp3_support")
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
exit(-1)

print("Running a test of your configuration...\n")

if torch.cuda.is_available():
device_id = torch.cuda.current_device()
gpu_properties = torch.cuda.get_device_properties(device_id)
Expand Down Expand Up @@ -123,8 +133,10 @@
message = "Reference voice: enter an audio filepath of a voice to be cloned (mp3, " \
"wav, m4a, flac, ...):\n"
in_fpath = Path(input(message).replace("\"", "").replace("\'", ""))



if (str(in_fpath)[-3:] == "mp3"):
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
print("Can't Use mp3 files please try again:")
in_fpath = Path(input(message).replace("\"", "").replace("\'", ""))
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
## Computing the embedding
# First, we load the wav using the function that the speaker encoder provides. This is
# important: there is preprocessing that must be applied.
Expand Down
2 changes: 2 additions & 0 deletions demo_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"overhead but allows to save some GPU memory for lower-end GPUs.")
parser.add_argument("--seed", type=int, default=None, help=\
"Optional random number seed value to make toolbox deterministic.")
parser.add_argument("--no_mp3_support", action="store_true", help=\
"If True, no mp3 files are allowed.")
args = parser.parse_args()
print_args(args, parser)

Expand Down
Binary file added sample/sample_MP3.mp3
Binary file not shown.
20 changes: 16 additions & 4 deletions toolbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import traceback
import sys
import torch

import librosa
from audioread.exceptions import NoBackendError

# Use this directory structure for your datasets, or modify it to fit your needs
recognized_datasets = [
Expand Down Expand Up @@ -39,7 +40,14 @@
MAX_WAVES = 15

class Toolbox:
def __init__(self, datasets_root, enc_models_dir, syn_models_dir, voc_models_dir, low_mem, seed):
def __init__(self, datasets_root, enc_models_dir, syn_models_dir, voc_models_dir, low_mem, seed, no_mp3_support):
if not no_mp3_support:
try:
librosa.load(r"sample\sample_MP3.mp3")
except NoBackendError:
print("NoBackendError Exceptions raised please Install ffmpeg or rerun using no_mp3_support")
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
exit(-1)

ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
sys.excepthook = self.excepthook
self.datasets_root = datasets_root
self.low_mem = low_mem
Expand All @@ -64,7 +72,7 @@ def __init__(self, datasets_root, enc_models_dir, syn_models_dir, voc_models_dir
self.reset_ui(enc_models_dir, syn_models_dir, voc_models_dir, seed)
self.setup_events()
self.ui.start()

def excepthook(self, exc_type, exc_value, exc_tb):
traceback.print_exception(exc_type, exc_value, exc_tb)
self.ui.log("Exception: %s" % exc_value)
Expand Down Expand Up @@ -149,7 +157,11 @@ def load_from_browser(self, fpath=None):
else:
name = fpath.name
speaker_name = fpath.parent.name


if (str(fpath)[-3:] == "mp3"):
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
print("Error: No mp3 file argument was passed but an mp3 file was used")
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved
exit(-1)
ramalamadingdong marked this conversation as resolved.
Show resolved Hide resolved

# Get the wav from the disk. We take the wav with the vocoder/synthesizer format for
# playback, so as to have a fair comparison with the generated audio
wav = Synthesizer.load_preprocess_wav(fpath)
Expand Down