rany2 / edge-srt-to-speech

Convert SubRip to speech using Microsoft Edge's TTS service
https://pypi.org/project/edge-srt-to-speech/
GNU General Public License v3.0
43 stars 10 forks source link

Error when not using SSML template #4

Closed photkey closed 2 years ago

photkey commented 2 years ago

edge-srt-to-speech .\example.srt test.mp3 --voice zh-CN-YunyangNeural --default-speed +1% --default-pitch +1Hz --default-volume +1%

Generating audio:   0%|                                 | 0/591 [00:00<?, ?it/s]Traceback (most recent call last):
  File "d:\develop\python\python38\lib\site-packages\edge_srt_to_speech\__main__.py", line 256, in _main
    await f
  File "d:\develop\python\python38\lib\asyncio\tasks.py", line 619, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "d:\develop\python\python38\lib\site-packages\edge_srt_to_speech\__main__.py", line 146, in audio_gen
    arg, text = get_enhanced_srt_params(text, arg, ssml_variables)
  File "d:\develop\python\python38\lib\site-packages\edge_srt_to_speech\__main__.py", line 126, in get_enhanced_srt_params
    raise ValueError("edge_tts{} is invalid")
ValueError: edge_tts{} is invalid

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\develop\python\python38\lib\shutil.py", line 616, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] Another program is using this file and the process cannot access it.: 'C:\\Users\\tuike\\AppData\\Local\\Temp\\tmpx18h1lws\\0.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\develop\python\python38\lib\tempfile.py", line 802, in onerror
    _os.unlink(path)
PermissionError: [WinError 32] Another program is using this file and the process cannot access it.: 'C:\\Users\\tuike\\AppData\\Local\\Temp\\tmpx18h1lws\\0.mp3'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\develop\python\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\develop\python\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Develop\Python\Python38\Scripts\edge-srt-to-speech.exe\__main__.py", line 7, in <module>
  File "d:\develop\python\python38\lib\site-packages\edge_srt_to_speech\__main__.py", line 367, in main
    asyncio.get_event_loop().run_until_complete(
  File "d:\develop\python\python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "d:\develop\python\python38\lib\site-packages\edge_srt_to_speech\__main__.py", line 317, in _main
    pdbar.close()
  File "d:\develop\python\python38\lib\tempfile.py", line 827, in __exit__
    self.cleanup()
  File "d:\develop\python\python38\lib\tempfile.py", line 831, in cleanup
    self._rmtree(self.name)
  File "d:\develop\python\python38\lib\tempfile.py", line 813, in _rmtree
    _shutil.rmtree(name, onerror=onerror)
  File "d:\develop\python\python38\lib\shutil.py", line 740, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "d:\develop\python\python38\lib\shutil.py", line 618, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "d:\develop\python\python38\lib\tempfile.py", line 805, in onerror
    cls._rmtree(path)
  File "d:\develop\python\python38\lib\tempfile.py", line 813, in _rmtree
    _shutil.rmtree(name, onerror=onerror)
  File "d:\develop\python\python38\lib\shutil.py", line 740, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "d:\develop\python\python38\lib\shutil.py", line 599, in _rmtree_unsafe
    onerror(os.scandir, path, sys.exc_info())
  File "d:\develop\python\python38\lib\shutil.py", line 596, in _rmtree_unsafe
    with os.scandir(path) as scandir_it:
NotADirectoryError: [WinError 267] The directory name is invalid.: 'C:\\Users\\tuike\\AppData\\Local\\Temp\\tmpx18h1lws\\0.mp3'
Generating audio:   0%|                                 | 0/591 [00:00<?, ?it/s]
rany2 commented 2 years ago

Are you sure the *.srt doesn't have any variables that are invalid?

For example:

1
00:00:00,596 --> 00:00:04,744
Hello world, I am very happy!
edge_tts{emotion:depressed}

will only be valid if the template contains emotion variable. If you're not using a template then it would be invalid because there is no emotion... only rate, volume, pitch, voice, etc

photkey commented 2 years ago

You spotted the problem at a glance, indeed.

rany2 commented 2 years ago

This project certainly needs some documentation

rany2 commented 2 years ago

and maybe more helpful error messages

photkey commented 2 years ago

After the project is perfected, I'll help you into translating a Chinese document, as well as doing some Chinese promotion.