Skip to content

Commit

Permalink
Merge pull request #19 from collective/check_if_js_available
Browse files Browse the repository at this point in the history
Check if responsiveVoice is available
  • Loading branch information
hvelarde committed Jun 14, 2016
2 parents 558b550 + 18a4f7b commit 0946286
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 13 deletions.
17 changes: 15 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ Mostly Harmless

Got an idea? Found a bug? Let us know by `opening a support <https://github.com/collective/collective.texttospeech/issues>`_.

Known Issues
------------

– Voice playback rate is slow on Android native browser
– Voice is cut off in shorter text on Android native browser
– Audio doesn’t play on Firefox Android

For more information, see `ResponsiveVoice FAQ <http://responsivevoice.org/faq/>`_.

Some browser add-ons (e.g., `Privacy Badger <https://www.eff.org/privacybadger>`_), could block ResponsiveVoice library disabling the Text-to-Speech feature.
In those cases the '🔊 Listen' button will not be available,
neither the Text-To-Speech control panel configlet will work.

Don't Panic
===========

Expand Down Expand Up @@ -71,7 +84,7 @@ Select which content types will have the feature enabled and select which voice

The Text-To-Speech control panel configlet.

A viewlet with a 'Play' button will be displayed on objects with the feature enabled.
A viewlet with a '🔊 Listen' button will be displayed on objects with the feature enabled.

.. figure:: docs/viewlet.png
:align: center
Expand All @@ -80,4 +93,4 @@ A viewlet with a 'Play' button will be displayed on objects with the feature ena

The Text-To-Speech feature enabled.

You can pause the reader at any time by selecting 'Pause'.
You can pause/resume the reader at any time by selecting 'Pause'/'▶ Resume'.
Binary file modified docs/viewlet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/collective/texttospeech/browser/templates/texttospeech.pt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
data-label-stopped="🔊 Listen"
data-label-playing="⏸ Pause"
data-label-paused="▶ Resume"
tal:condition="view/enabled"
tal:attributes="data-voice view/voice"
data-error-message="Could not load ResponsiveVoice library; Text-To-Speech feature will not be available."
tal:attributes="data-voice view/voice;
data-enabled view/enabled"
i18n:attributes="data-label-stopped;
data-label-playing;
data-label-paused">
data-label-paused;
data-error-message">
<input id="texttospeech-button"
class="stopped"
type="button"
value="🔊 Listen"
title="Speech synthesis control"
tal:condition="view/enabled"
i18n:attributes="value; title" />
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2016-06-10 21:35+0000\n"
"POT-Creation-Date: 2016-06-14 15:02+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI +ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
Expand All @@ -18,6 +18,10 @@ msgstr ""
msgid "Add Text-to-Speech feature to Plone."
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Could not load ResponsiveVoice library; Text-To-Speech feature will not be available."
msgstr ""

#: collective/texttospeech/interfaces.py:19
msgid "Enable Text-to-Speech?"
msgstr ""
Expand All @@ -38,7 +42,7 @@ msgstr ""
msgid "Only objects of these content types will display a Text-to-Speech button."
msgstr ""

#: collective/texttospeech/browser/templates/texttospeech.pt:11
#: collective/texttospeech/browser/templates/texttospeech.pt:13
msgid "Speech synthesis control"
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-06-10 21:35+0000\n"
"PO-Revision-Date: 2016-06-10 18:35-0300\n"
"POT-Creation-Date: 2016-06-14 15:02+0000\n"
"PO-Revision-Date: 2016-06-14 12:03-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -21,6 +21,10 @@ msgstr ""
msgid "Add Text-to-Speech feature to Plone."
msgstr "Adiciona la funcionalidad de síntesis de habla a Plone."

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Could not load ResponsiveVoice library; Text-To-Speech feature will not be available."
msgstr "No fue posible cargar la biblioteca ResponsiveVoice; la funcionalidad de síntesis de habla no estará disponible."

#: collective/texttospeech/interfaces.py:19
msgid "Enable Text-to-Speech?"
msgstr "¿Habilitar síntesis de habla?"
Expand All @@ -41,7 +45,7 @@ msgstr "Si está seleccionado, la funcionalidad de síntesis de habla estará ha
msgid "Only objects of these content types will display a Text-to-Speech button."
msgstr "Sólo los objetos de estos tipos de contenido mostrarán el botón de síntesis de habla."

#: collective/texttospeech/browser/templates/texttospeech.pt:11
#: collective/texttospeech/browser/templates/texttospeech.pt:13
msgid "Speech synthesis control"
msgstr "Control de la síntesis de habla"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2016-06-10 21:35+0000\n"
"PO-Revision-Date: 2016-06-10 18:35-0300\n"
"POT-Creation-Date: 2016-06-14 15:02+0000\n"
"PO-Revision-Date: 2016-06-14 12:12-0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
Expand All @@ -21,6 +21,10 @@ msgstr ""
msgid "Add Text-to-Speech feature to Plone."
msgstr "Adiciona a funcionalidade de síntese de voz ao Plone."

#: collective/texttospeech/browser/templates/texttospeech.pt:1
msgid "Could not load ResponsiveVoice library; Text-To-Speech feature will not be available."
msgstr "Não foi possível carregar a biblioteca ResponsiveVoice; a funcionalidade de síntese de voz não estará disponível."

#: collective/texttospeech/interfaces.py:19
msgid "Enable Text-to-Speech?"
msgstr "Habilitar síntese de voz?"
Expand All @@ -41,7 +45,7 @@ msgstr "Se estiver selecionado, a funcionalidade de síntese de voz estará habi
msgid "Only objects of these content types will display a Text-to-Speech button."
msgstr "Só objetos de esses tipos de conteúdo mostrarão o botão de síntese de voz."

#: collective/texttospeech/browser/templates/texttospeech.pt:11
#: collective/texttospeech/browser/templates/texttospeech.pt:13
msgid "Speech synthesis control"
msgstr "Controle da síntese de voz"

Expand Down
12 changes: 12 additions & 0 deletions src/collective/texttospeech/static/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
var MainView = (function() {
function MainView() {
this.$el = $('#viewlet-texttospeech');
if (typeof window.responsiveVoice === "undefined") {
this.$el.html('');
var error_message = this.$el.attr('data-error-message');
console.log(error_message);
return;
}
this.$button = $('#texttospeech-button', this.$el);
this.voice = this.$el.attr('data-voice');
this.label_stopped = this.$el.attr('data-label-stopped');
Expand Down Expand Up @@ -49,6 +55,12 @@ var MainView = (function() {

var ControlPanelView = (function() {
function ControlPanelView() {
if (typeof window.responsiveVoice === "undefined") {
var $el = $('#viewlet-texttospeech');
var error_message = $el.attr('data-error-message');
alert(error_message);
return;
}
this.template = "<select id=\"form-widgets-voice\" name=\"form.widgets.voice\" class=\"text-widget required textline-field\">\n</select>";
this.actual_voice = $('#form-widgets-voice').val();
this.render();
Expand Down

0 comments on commit 0946286

Please sign in to comment.