hakka_tts.py 930 B

12345678910111213141516171819202122232425262728
  1. # !pip install librosa==0.7.2
  2. # !pip install numba==0.48.0
  3. # !pip install pydub
  4. import pandas as pd
  5. import numpy as np
  6. import re
  7. import jieba
  8. import jieba.posseg as pseg
  9. import urllib
  10. import urllib.request
  11. import librosa
  12. from pydub import AudioSegment
  13. from pydub.silence import split_on_silence
  14. import itertools
  15. from util import *
  16. if __name__ == '__main__':
  17. mp3_path='test1.mp3'
  18. ch_sentence = "資料分析是我的工作"
  19. download = False #如果要下載才需要Ture
  20. hakka_100 = import_hakka_100()
  21. word_data,multi_sound = import_data()
  22. if download:
  23. download_mp3(word_data,multi_sound)
  24. download_hakka_100(hakka_100)
  25. ch_word_list = list(itertools.chain(*word_data['華語詞義集'].tolist())) + hakka_100.chinese_clean.tolist()
  26. import_jieba_userdict(ch_word_list=ch_word_list, userDict_path='userDict.txt')
  27. gen_hakka_tts(word_data,multi_sound,hakka_100,ch_sentence,mp3_path)