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

JSON object must be str, bytes or bytearray, not 'NoneType' #163

Open
orophix opened this issue Feb 20, 2021 · 8 comments
Open

JSON object must be str, bytes or bytearray, not 'NoneType' #163

orophix opened this issue Feb 20, 2021 · 8 comments

Comments

@orophix
Copy link

orophix commented Feb 20, 2021

Make sure you have read the readme, searched and read the issues related to yours. Otherwise it will be considered as a duplicate which will be closed immediately.

Describe the bug
Errors when trying to run.
To Reproduce
Steps to reproduce the behavior:

  • Command line arguments you are using.Use the following markdown code block syntax is recommended. Copy them into the place between ```.
file = 'file.mp4'
src_language = 'ja' 
dst_language = 'en'
output_format = 'ass'

autosub -i {file} -S {src_language} -D {dst_language} -F {output_format} -o {file}.{output_format}

  • A complete copy of command line output of the autosub. You can use Ctrl-A and Ctrl-C to copy all of them.
Sending short-term fragments to Google Speech V2 API and getting result.
Speech-to-Text: 100% |##########################################| Time:  0:02:27
Traceback (most recent call last):
  File "/usr/local/bin/autosub", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/dist-packages/autosub/__init__.py", line 162, in main
    styles_list=styles_list)
  File "/usr/local/lib/python3.6/dist-packages/autosub/cmdline_utils.py", line 1628, in audio_or_video_prcs
    delete_chars=args.trans_delete_chars)
  File "/usr/local/lib/python3.6/dist-packages/autosub/core.py", line 772, in list_to_googletrans
    result_src = translator.detect(content_to_trans).lang
  File "/usr/local/lib/python3.6/dist-packages/googletrans/client.py", line 369, in detect
    translated = self.translate(text, src='auto', dest='en')
  File "/usr/local/lib/python3.6/dist-packages/googletrans/client.py", line 219, in translate
    parsed = json.loads(data[0][2])
  File "/usr/lib/python3.6/json/__init__.py", line 348, in loads
    'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'
  • If a config file is used, attach the config file, but be sure to remove any information related to your accounts.
Use this to display your config.
  • etc.

Expected behavior
A clear and concise description of what you expected to happen.

To complete without error.

Screenshots
If applicable, add screenshots to help explain your problem. But it is not recommended using screenshots to demonstrate the commandline output unless you think it really matters.

Environment (please complete the following information):

  • OS: [Ubuntu 18.04]
  • Python Version: [3]
  • Autosub Version: [Latest Dev]

Additional context (Optional)
Add any other context about the problem here.

@BingLingGroup
Copy link
Owner

BingLingGroup commented Feb 21, 2021

It seems to be this ssut/py-googletrans#234 caused by py-googletrans. Perhaps replacing the dependency to https://github.com/Saravananslb/py-googletranslation may solve this issue.

Currently if you don't have too many subtitles files to do a bulk translation, you can use the following command to do a manual-copy-and-paste translation. (Not listed in the readme)

autosub -i {file} -tapi man -of dst -doc -mts 9820 -tf txt -F ass

This will generate a txt file which contain a certain amount of words to be translated. Then you copy them to any of the translation website such as https://www.deepl.com/translator. After that you copy all the translation results from the website and then overwrite all the content in the previous txt. Then input enter in autosub and do these again until all the content being translated and the translated subtitles will be generated.

@orophix
Copy link
Author

orophix commented Feb 22, 2021

Is there an easy way to make it use py-google translation instead?

@BingLingGroup
Copy link
Owner

I tried these arguments and it works.

autosub -SRC en -D zh -surl translate.google.com -slp 0.1

@zhenghan3
Copy link

It seems to be this ssut/py-googletrans#234 caused by py-googletrans. Perhaps replacing the dependency to https://github.com/Saravananslb/py-googletranslation may solve this issue.

Currently if you don't have too many subtitles files to do a bulk translation, you can use the following command to do a manual-copy-and-paste translation. (Not listed in the readme)

autosub -i {file} -tapi man -of dst -doc -mts 9820 -tf txt -F ass

This will generate a txt file which contain a certain amount of words to be translated. Then you copy them to any of the translation website such as https://www.deepl.com/translator. After that you copy all the translation results from the website and then overwrite all the content in the previous txt. Then input enter in autosub and do these again until all the content being translated and the translated subtitles will be generated.

tried with the command and got the error
"autosub: error: unrecognized arguments: -tapi man -mts 9820 -tf txt"

@BingLingGroup
Copy link
Owner

@zhenghan3 You need to use the latest dev version in the github repo dev branch.

@abrichr
Copy link

abrichr commented Apr 23, 2021

Not working for me on MacOS:

$ git status
On branch dev
Your branch is up to date with 'origin/dev'.

nothing to commit, working tree clean
$
$ git log -n 1
commit 0d6687831e69195d31d66d503b50113a3939501f (HEAD -> dev, origin/dev, origin/HEAD)
Author: BingLingGroup <[email protected]>
Date:   Tue Mar 23 15:14:13 2021 +0800

    Fix unable to type into the terminal after running
$ 
$ autosub -i out.mkv -S de-DE -D en -surl translate.google.com -slp 0.1
...
Sending short-term fragments to Google Speech V2 API and getting result.                                                                                                             
Speech-to-Text: 100% |##############################################################################################################################################| Time:  0:07:15 
Traceback (most recent call last):                                                                                                                                                   
...
TypeError: the JSON object must be str, bytes or bytearray, not NoneType  

Edit: after including the SRC option it works:

$ autosub -i out.mkv -S de-DE -SRC de -D en              
                                                                                                                                                                                     
Convert source file to "/var/folders/35/pqjnmmwx24d2mtf4frt5dhcc0000gn/T/tmpd8rnw4uf.wav" to detect audio regions.
/usr/local/bin/ffmpeg -hide_banner -y -i "out.mkv" -vn -ac 1 -ar 48000 -loglevel error "/var/folders/35/pqjnmmwx24d2mtf4frt5dhcc0000gn/T/tmpd8rnw4uf.wav"
                                                                                                                                                                                     
Use ffprobe to check conversion result.
/usr/local/bin/ffprobe "/var/folders/35/pqjnmmwx24d2mtf4frt5dhcc0000gn/T/tmpd8rnw4uf.wav" -show_format -pretty -loglevel quiet
[FORMAT]                                                                                                                                                                             
filename=/var/folders/35/pqjnmmwx24d2mtf4frt5dhcc0000gn/T/tmpd8rnw4uf.wav              
nb_streams=1
nb_programs=0 
format_name=wav                                                                           
format_long_name=WAV / WAVE (Waveform Audio)
start_time=N/A                                                                            
duration=0:00:25.493333                                                                                                                                                              
size=2.334059 Mibyte
bit_rate=768.024000 Kbit/s                                                                                                                                                           
probe_score=99                                                                                                                                                                       
TAG:encoder=Lavf58.45.100
[/FORMAT]                              
                                                                                                                                                                                     
Conversion completed.
Use Auditok to detect speech regions.                                                     
Auditok detection completed.
"/var/folders/35/pqjnmmwx24d2mtf4frt5dhcc0000gn/T/tmpd8rnw4uf.wav" has been deleted.
                                             
Converting speech regions to short-term fragments.
Converting: 100% |##################################################################################################################################################| Time:  0:00:00
                                             
Sending short-term fragments to Google Speech V2 API and getting result.
Speech-to-Text: 100% |##############################################################################################################################################| Time:  0:00:04
                                             
Translating text from "de" to "en".
Translation: 100% |#################################################################################################################################################| Time:  0:00:00
Destination language subtitles file created at "/tmp/autosub/out.en.srt".
                                             
All work done.

@tangjiahaodw
Copy link

20220510,[0.5.7-alpha]windows发布版使用翻译功能报错'NoneType' object has no attribute 'group',请问如何解决?

@BingLingGroup
Copy link
Owner

20220510,[0.5.7-alpha]windows发布版使用翻译功能报错'NoneType' object has no attribute 'group',请问如何解决?

#163 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants