One-Shot-Voice-Cloning icon indicating copy to clipboard operation
One-Shot-Voice-Cloning copied to clipboard

import error : from tensorflow_tts.audio_process import preprocess_wav

Open wwdok opened this issue 2 years ago • 11 comments

I just installed TensorFlowTTS whose version is 1.8 by pip install TensorFlowTTS , but when i open the notebook\OneShotVoiceClone_Inference.ipynb, it shows import error: image it seems the 1.8 version TensorFlowTTS does not have audio_process module, but i also notice the root folder has a TensorFlowTTS folder, maybe i can install it instead, do you plan to compatible with 1.8 version TensorFlowTTS ?

wwdok avatar Feb 21 '22 16:02 wwdok

Because it is developed based on the repository (TensorflowTTS), it should be at least tensorflow 2.0 or higher. You are using 1.8, which may not be supported by many libraries. Showing this message “No module ...”, I guess "pip install" is failed.

CMsmartvoice avatar Feb 22 '22 09:02 CMsmartvoice

I met the same error too, I found this can be resolved by installing TensorFlowTTS from this repo given.

cd TensorFlowTTS
python setup.py install

zoezhu avatar Feb 22 '22 10:02 zoezhu

@CMsmartvoice My tensorflow version is 2.6, and tensorflowTTS version is 1.8. @zoezhu Yes, this is a workaround, but this method is a little indirect and not been pointed out in the doc, i just afraid afterwards many people will encounter this error.

wwdok avatar Feb 22 '22 14:02 wwdok

@wwdok Yes, I did encounter it! And then to run: from UnetTTS_syn import UnetTTS I had to move UnetTTS_syn.py under the TTS foulder. Did you too encountered the same problem??

ireneb612 avatar Feb 22 '22 14:02 ireneb612

@ireneb612 I didn't change any path of any file or any folder, i first run pip uninstall tensorflowTTS, then try zoezhu's method python setup.py install, but unfortunately it gave me error :

C:\ProgramData\Miniconda3\include\pyconfig.h(59): fatal error C1083: Can not open include file: “io.h”: No such file or d
irectory
error: Setup script exited with error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

Then i tried another method: add sys.path.append("../TensorFlowTTS") in the notebook, but when it runs to syn_audio, mel_pred, mel_src = Tts_handel.one_shot_TTS(text, src_audio, is_wrap_txt=False), I encounter new error:

NotImplementedError: in user code:

    ../TensorFlowTTS\tensorflow_tts\models\unetts.py:229 _inference  *
        content_latents, encoder_masks = self.content_encoder(char_ids, duration_gts, training=False)
    ../TensorFlowTTS\tensorflow_tts\models\unetts.py:170 call  *
        length_regulator_outputs, encoder_masks = self.length_regulator(
    ../TensorFlowTTS\tensorflow_tts\models\moduls\core.py:604 call  *
        outputs, encoder_masks = self._length_regulator(
    ../TensorFlowTTS\tensorflow_tts\models\moduls\core.py:638 _length_regulator  *
        outputs = tf.zeros(shape=[0, max_durations, hidden_size + self.addfeatures_num], dtype=encoder_hidden_states.dtype)
    C:\ProgramData\Miniconda3\lib\site-packages\tensorflow\python\util\dispatch.py:201 wrapper  **
        return target(*args, **kwargs)
    C:\ProgramData\Miniconda3\lib\site-packages\tensorflow\python\ops\array_ops.py:2747 wrapped
        tensor = fun(*args, **kwargs)
    C:\ProgramData\Miniconda3\lib\site-packages\tensorflow\python\ops\array_ops.py:2794 zeros
        output = _constant_if_small(zero, shape, dtype, name)
    C:\ProgramData\Miniconda3\lib\site-packages\tensorflow\python\ops\array_ops.py:2732 _constant_if_small
        if np.prod(shape) < 1000:
    <__array_function__ internals>:5 prod
        
    C:\ProgramData\Miniconda3\lib\site-packages\numpy\core\fromnumeric.py:3051 prod
        return _wrapreduction(a, np.multiply, 'prod', axis, dtype, out,
    C:\ProgramData\Miniconda3\lib\site-packages\numpy\core\fromnumeric.py:86 _wrapreduction
        return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
    C:\ProgramData\Miniconda3\lib\site-packages\tensorflow\python\framework\ops.py:845 __array__
        raise NotImplementedError(

NotImplementedError: Cannot convert a symbolic Tensor (content_encoder/length_regulator/Max:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

So by now I have not succussfully run through this notebook...

wwdok avatar Feb 22 '22 15:02 wwdok

@wwdok I managed to run it, you should do these commands in a row:

! git clone https://github.com/CMsmartvoice/One-Shot-Voice-Cloning.git %cd One-Shot-Voice-Cloning/TensorFlowTTS/ !python setup.py install %cd ..

MOVE UnetTTS_syn.py INSIDE TTSFlowTTS <----

from UnetTTS_syn import UnetTTS from tensorflow_tts.audio_process import preprocess_wav import os os.environ["CUDA_VISIBLE_DEVICES"]= "0" from pathlib import Path

ETC.... like the colab

ireneb612 avatar Feb 22 '22 16:02 ireneb612

@wwdok This problem may be related to windows Visual Studio. It is suggested that it can be executed under linux system or windows wsl system

CMsmartvoice avatar Feb 23 '22 01:02 CMsmartvoice

@ireneb612 You don't really need to move the file; since the custom UnetTTS_syn.py is not under the search path of the python library, just add its path before each execution, e.g. sys.path.append("...").

CMsmartvoice avatar Feb 23 '22 01:02 CMsmartvoice

@CMsmartvoice I have applied the access permission of online colab notebook, could you please approve it ?

wwdok avatar Feb 23 '22 02:02 wwdok

@wwdok I've updated the permissions to see if you can now.

CMsmartvoice avatar Feb 23 '22 03:02 CMsmartvoice

@CMsmartvoice Yes, I can access the colab notebook now, thank you !

wwdok avatar Feb 24 '22 01:02 wwdok