myshell-ai / MeloTTS

High-quality multi-lingual text-to-speech library by MyShell.ai. Support English, Spanish, French, Chinese, Japanese and Korean.
MIT License
4.75k stars 615 forks source link

BadZipFile: File is not a zip file #165

Closed gabrielpondc closed 3 months ago

gabrielpondc commented 3 months ago
from melo.api import TTS

Error

---------------------------------------------------------------------------
BadZipFile                                Traceback (most recent call last)
Cell In[4], <a href='vscode-notebook-cell:?execution_count=4&line=1'>line 1</a>
----> <a href='vscode-notebook-cell:?execution_count=4&line=1'>1</a> from melo.api import TTS

File /2T/speechreg/CosyVoice/MeloTTS/melo/api.py:13
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/api.py:10'>10</a> from tqdm import tqdm
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/api.py:11'>11</a> import torch
---> <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/api.py:13'>13</a> from . import utils
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/api.py:14'>14</a> from . import commons
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/api.py:15'>15</a> from .models import SynthesizerTrn

File /2T/speechreg/CosyVoice/MeloTTS/melo/utils.py:13
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/utils.py:11'>11</a> import librosa
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/utils.py:12'>12</a> from melo.text import cleaned_text_to_sequence, get_bert
---> <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/utils.py:13'>13</a> from melo.text.cleaner import clean_text
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/utils.py:14'>14</a> from melo import commons
     <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/utils.py:16'>16</a> MATPLOTLIB_FLAG = False

File /2T/speechreg/CosyVoice/MeloTTS/melo/text/cleaner.py:1
----> <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/cleaner.py:1'>1</a> from . import chinese, japanese, english, chinese_mix, korean, french, spanish
      <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/cleaner.py:2'>2</a> from . import cleaned_text_to_sequence
      <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/cleaner.py:3'>3</a> import copy

File /2T/speechreg/CosyVoice/MeloTTS/melo/text/english.py:4
      <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/english.py:2'>2</a> import os
      <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/english.py:3'>3</a> import re
----> <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/english.py:4'>4</a> from g2p_en import G2p
      <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/english.py:6'>6</a> from . import symbols
      <a href='/2T/speechreg/CosyVoice/MeloTTS/melo/text/english.py:8'>8</a> from .english_utils.abbreviations import expand_abbreviations

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/__init__.py:1
----> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/__init__.py:1'>1</a> from .g2p import G2p

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/g2p.py:22
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/g2p.py:19'>19</a> from .expand import normalize_numbers
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/g2p.py:21'>21</a> try:
---> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/g2p.py:22'>22</a>     nltk.data.find('taggers/averaged_perceptron_tagger.zip')
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/g2p.py:23'>23</a> except LookupError:
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/g2p_en/g2p.py:24'>24</a>     nltk.download('averaged_perceptron_tagger')

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:542, in find(resource_name, paths)
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:540'>540</a> if os.path.exists(p):
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:541'>541</a>     try:
--> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:542'>542</a>         return ZipFilePathPointer(p, zipentry)
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:543'>543</a>     except OSError:
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:544'>544</a>         # resource not in zipfile
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:545'>545</a>         continue

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:41, in py3_data.<locals>._decorator(*args, **kwargs)
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:39'>39</a> def _decorator(*args, **kwargs):
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:40'>40</a>     args = (args[0], add_py3_data(args[1])) + args[2:]
---> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:41'>41</a>     return init_func(*args, **kwargs)

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:394, in ZipFilePathPointer.__init__(self, zipfile, entry)
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:386'>386</a> """
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:387'>387</a> Create a new path pointer pointing at the specified entry
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:388'>388</a> in the given zipfile.
   (...)
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:391'>391</a> does not contain the specified entry.
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:392'>392</a> """
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:393'>393</a> if isinstance(zipfile, str):
--> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:394'>394</a>     zipfile = OpenOnDemandZipFile(os.path.abspath(zipfile))
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:396'>396</a> # Check that the entry exists:
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:397'>397</a> if entry:
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:398'>398</a> 
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:399'>399</a>     # Normalize the entry string, it should be relative:

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:41, in py3_data.<locals>._decorator(*args, **kwargs)
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:39'>39</a> def _decorator(*args, **kwargs):
     <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:40'>40</a>     args = (args[0], add_py3_data(args[1])) + args[2:]
---> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/compat.py:41'>41</a>     return init_func(*args, **kwargs)

File ~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:935, in OpenOnDemandZipFile.__init__(self, filename)
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:933'>933</a> if not isinstance(filename, str):
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:934'>934</a>     raise TypeError("ReopenableZipFile filename must be a string")
--> <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:935'>935</a> zipfile.ZipFile.__init__(self, filename)
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:936'>936</a> assert self.filename == filename
    <a href='~/anaconda3/envs/openvoice/lib/python3.9/site-packages/nltk/data.py:937'>937</a> self.close()

File ~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1268, in ZipFile.__init__(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps)
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1266'>1266</a> try:
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1267'>1267</a>     if mode == 'r':
-> <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1268'>1268</a>         self._RealGetContents()
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1269'>1269</a>     elif mode in ('w', 'x'):
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1270'>1270</a>         # set the modified flag so central directory gets written
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1271'>1271</a>         # even if no files are added to the archive
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1272'>1272</a>         self._didModify = True

File ~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1335, in ZipFile._RealGetContents(self)
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1333'>1333</a>     raise BadZipFile("File is not a zip file")
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1334'>1334</a> if not endrec:
-> <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1335'>1335</a>     raise BadZipFile("File is not a zip file")
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1336'>1336</a> if self.debug > 1:
   <a href='~/anaconda3/envs/openvoice/lib/python3.9/zipfile.py:1337'>1337</a>     print(endrec)

BadZipFile: File is not a zip file
gabrielpondc commented 3 months ago

I have already found the solve method that initiation the ~/nltk_data

AGENDD commented 2 months ago

Hey, I meet the same problem. How do you fix it?