Skip to content

Commit

Permalink
默认朗读更换为百度 tts API
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Apr 17, 2020
1 parent 3660770 commit ca131c6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
![GitHub stars](https://img.shields.io/github/stars/Benature/WordReview?style=flat)
![GitHub stars](https://img.shields.io/github/forks/Benature/WordReview?style=flat)
![GitHub issues](https://img.shields.io/github/issues/Benature/WordReview)
![GitHub closed issues](https://img.shields.io/github/issues-closed/Benature/WordReview)
![GitHub](https://img.shields.io/github/license/Benature/WordReview)

Django + MySQL + Pug + JS
Expand Down
6 changes: 4 additions & 2 deletions apps/review/templates/review.pug
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ div.container.flex-column
div.hide#word-sand(style="font-size:12px;max-width: 400px;")
//- iframe(stc="http://baidu.comdict.cn/mini.php?q=idle")
form
input#clipboard(style="position: absolute;top: 0;")
input#clipboard(style="position: absolute;top: 0;")

div#bd-tts
{% endblock %}
1 change: 0 additions & 1 deletion apps/review/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def update_word_flag(request):
def spider_dict_mini(request):
'''API: spider to crawl http://dict.cn/mini.php'''
status, data = crawl_dict_mini(request.POST.get('word'))
print(status, data)
return JsonResponse({
'status': status,
'data': data,
Expand Down
6 changes: 4 additions & 2 deletions doc/database_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ excel_path = 'data/sample.xlsx'

一些资源整合:
- [IELTS 绿皮书](https://blog.csdn.net/M_sdn/article/details/85532520?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task)
- [要你命 3000](https://github.com/skywind3000/ECDICT)
- [再要你命三千](https://github.com/liurui39660/3000)
- [TOEFL 曲根单词](https://github.com/yihui-he/TOEFL-10000-0)
- [一个强大开源中英字典](https://github.com/skywind3000/ECDICT)

欢迎大家补充

欢迎大家补充
14 changes: 11 additions & 3 deletions static/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ function copy2Clipboard(content, idN) {
}
}

function readText(word) {
let speechInstance = new SpeechSynthesisUtterance(word);
speechSynthesis.speak(speechInstance);
function readText(word, source = 'baidu') {
if (source == 'baidu') {
document.getElementById('bd-tts').innerHTML =
'<audio id="bd-tts-audio" autoplay="autoplay">' +
'<source src="http://tts.baidu.com/text2audio?lan=en&ie=UTF-8&spd=3&text=' +
word + '" type="audio/mpeg"><embed id="tts_embed_id" height="0" width="0" src=""></audio>';
document.getElementById('bd-tts-audio').play();
} else if (source == 'browser') {
let speechInstance = new SpeechSynthesisUtterance(word);
speechSynthesis.speak(speechInstance);
}
}

0 comments on commit ca131c6

Please sign in to comment.