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

Issue with Basic Usage Code #775

Open
effy46 opened this issue Oct 8, 2024 · 1 comment
Open

Issue with Basic Usage Code #775

effy46 opened this issue Oct 8, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@effy46
Copy link

effy46 commented Oct 8, 2024

Here is the code I am using:

import ChatTTS
import torch
import torchaudio


chat = ChatTTS.Chat()
chat.load(compile=False) # Set to True for better performance

texts = ["All set. Lets go", "Lets get started,drive safe"]

wavs = chat.infer(texts)

for i in range(len(wavs)):
    """
    In some versions of torchaudio, the first line works but in other versions, so does the second line.
    """
    try:
        torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
    except:
        torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]), 24000)

I received below error:

e detected that you are passing `past_key_values` as a tuple of tuples. This is deprecated and will be removed in v4.47. Please convert your cache or use an appropriate `Cache` class (https://huggingface.co/docs/transformers/kv_cache#legacy-cache-format)
text:   3%|█████▋                                                                                                                                                                                | 12/384(max) [00:01,  6.15it/s]
code:   4%|███████▌                                                                                                                                                                             | 85/2048(max) [00:07, 10.64it/s]
Traceback (most recent call last):
  File "e:\Project\VoiceAI\ChatTTS\ChatTTS\sample.py", line 18, in <module>
    torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]).unsqueeze(0), 24000)
  File "C:\Users\fiona\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\torchaudio\_backend\utils.py", line 312, in save
    backend = dispatcher(uri, format, backend)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fiona\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\torchaudio\_backend\utils.py", line 222, in dispatcher
    raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
RuntimeError: Couldn't find appropriate backend to handle uri basic_output0.wav and format None.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "e:\Project\VoiceAI\ChatTTS\ChatTTS\sample.py", line 20, in <module>
    torchaudio.save(f"basic_output{i}.wav", torch.from_numpy(wavs[i]), 24000)
  File "C:\Users\fiona\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\torchaudio\_backend\utils.py", line 312, in save
    backend = dispatcher(uri, format, backend)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\fiona\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\torchaudio\_backend\utils.py", line 222, in dispatcher
    raise RuntimeError(f"Couldn't find appropriate backend to handle uri {uri} and format {format}.")
RuntimeError: Couldn't find appropriate backend to handle uri basic_output0.wav and format None.
@fumiama
Copy link
Member

fumiama commented Oct 9, 2024

Please put ffmpeg into PATH env variable.

@fumiama fumiama added the documentation Improvements or additions to documentation label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants