Files
AudioGPT/text_to_speech/utils/text/encoding.py
2023-03-25 15:29:57 +08:00

10 lines
207 B
Python

import chardet
def get_encoding(file):
with open(file, 'rb') as f:
encoding = chardet.detect(f.read())['encoding']
if encoding == 'GB2312':
encoding = 'GB18030'
return encoding