From ca131c67e71d4e491d47f06f4ea25039d39371af Mon Sep 17 00:00:00 2001 From: Benature Date: Fri, 17 Apr 2020 12:03:22 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=9C=97=E8=AF=BB=E6=9B=B4?= =?UTF-8?q?=E6=8D=A2=E4=B8=BA=E7=99=BE=E5=BA=A6=20tts=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + apps/review/templates/review.pug | 6 ++++-- apps/review/views.py | 1 - doc/database_init.md | 6 ++++-- static/js/util.js | 14 +++++++++++--- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 2943ad7..b19ff10 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/apps/review/templates/review.pug b/apps/review/templates/review.pug index 8c43749..b8a348f 100644 --- a/apps/review/templates/review.pug +++ b/apps/review/templates/review.pug @@ -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 %} \ No newline at end of file diff --git a/apps/review/views.py b/apps/review/views.py index 27a31dd..3aa3798 100644 --- a/apps/review/views.py +++ b/apps/review/views.py @@ -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, diff --git a/doc/database_init.md b/doc/database_init.md index eb090ec..e6e5c5e 100644 --- a/doc/database_init.md +++ b/doc/database_init.md @@ -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) -欢迎大家补充 \ No newline at end of file + +欢迎大家补充 diff --git a/static/js/util.js b/static/js/util.js index 631833d..f024572 100644 --- a/static/js/util.js +++ b/static/js/util.js @@ -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 = + ''; + document.getElementById('bd-tts-audio').play(); + } else if (source == 'browser') { + let speechInstance = new SpeechSynthesisUtterance(word); + speechSynthesis.speak(speechInstance); + } } \ No newline at end of file