Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1278 from benetech/feature/#1268-2
Browse files Browse the repository at this point in the history
Reading Crossouts
  • Loading branch information
rupeshparab authored Jul 3, 2020
2 parents 594f6b5 + ffd825f commit 5dbb258
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../../../../../../../../../images/pencil.png';
import '../../../../../../../../../images/delete.png';
import { passEventForKeys } from '../../../../../../../../services/events';
import TTSButton from '../../../../../../../TTSButton';
import { latexToSpeakableText } from '../../../../../../../../services/speech';

const mathLive = process.env.MATHLIVE_DEBUG_MODE ? require('../../../../../../../../../../mathlive/src/mathlive.js').default
: require('../../../../../../../../lib/mathlivedist/mathlive.js');
Expand All @@ -27,13 +28,7 @@ export default class Step extends Component {
setTimeout(mathLive.renderMathInDocument, 100); // failsafe to ensure mathlive conversion
}

getSpeakableText = () => mathLive.latexToSpeakableText(
this.props.cleanupValue || this.props.math,
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
);
getSpeakableText = () => latexToSpeakableText(this.props.cleanupValue || this.props.math);

getStepText = () => (
Locales.strings.step_tts_text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class MyWorkEditorArea extends Component {
},
textToSpeechMarkup: 'ssml',
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'ssml_step' },
textToSpeechRulesOptions: { domain: 'mathspeak', style: 'default', markup: 'ssml_step' },
speechEngine: 'amazon',
},
);
Expand Down
9 changes: 2 additions & 7 deletions src/components/Editor/components/MyWork/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Painterro from '../../../../lib/painterro/painterro.commonjs2';
import painterroConfiguration from './painterroConfiguration.json';
import TTSButton from '../../../TTSButton';
import { checkIfDescriptionIsRequired } from '../../stepsOperations';
import { latexToSpeakableText } from '../../../../services/speech';

const mathLive = process.env.MATHLIVE_DEBUG_MODE ? require('../../../../../../mathlive/src/mathlive.js').default
: require('../../../../lib/mathlivedist/mathlive.js');
Expand Down Expand Up @@ -122,13 +123,7 @@ class MyWork extends Component {
getSpeakableText = () => {
let math = '';
if (this.props.theActiveMathField) {
math = mathLive.latexToSpeakableText(
this.props.theActiveMathField.$latex(),
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
);
math = latexToSpeakableText(this.props.theActiveMathField.$latex());
}
return [math, this.props.textAreaValue].filter(value => value.trim() !== '').join('. ');
};
Expand Down
17 changes: 3 additions & 14 deletions src/components/Editor/components/ProblemHeader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import completeKeyMap from '../../../../constants/hotkeyConfig.json';
import { stopEvent } from '../../../../services/events';
import { tourConfig, accentColor } from './tourConfig';
import TTSButton from '../../../TTSButton';
import { latexToSpeakableText } from '../../../../services/speech';
// import parseMathLive from '../../../../scripts/parseMathLive';

const mathLive = process.env.MATHLIVE_DEBUG_MODE ? require('../../../../../../mathlive/src/mathlive.js').default
Expand Down Expand Up @@ -65,13 +66,7 @@ export default class ProblemHeader extends Component {
this.props.closeTour();
}

getSpeakableText = () => `${this.props.title} ${mathLive.latexToSpeakableText(
this.props.math,
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
)}`;
getSpeakableText = () => `${this.props.title} ${latexToSpeakableText(this.props.math)}`;

render() {
const imgButton = this.props.scratchpad
Expand Down Expand Up @@ -147,13 +142,7 @@ export default class ProblemHeader extends Component {
<h1 id="ProblemTitle" className={problem.title} tabIndex={-1}>
{title}
<span className="sROnly">
{mathLive.latexToSpeakableText(
this.props.math,
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
)}
{latexToSpeakableText(this.props.math)}
</span>
</h1>
{this.props.math !== Locales.strings.loading && (<span id="ProblemMath" className={`${problem.title} ${problem.question}`}>{`$$${this.props.math}$$`}</span>)}
Expand Down
9 changes: 2 additions & 7 deletions src/components/Home/components/Navigation/Problem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import parseMathLive from '../../../../../scripts/parseMathLive';
import { stopEvent, passEventForKeys } from '../../../../../services/events';
import CommonDropdown from '../../../../CommonDropdown';
import { getMathshareLink } from '../../../../../services/mathshare';
import { latexToSpeakableText } from '../../../../../lib/mathlivedist/mathlive';

const mathLive = process.env.MATHLIVE_DEBUG_MODE ? require('../../../../../../../mathlive/src/mathlive.js').default
: require('../../../../../lib/mathlivedist/mathlive.js');
Expand Down Expand Up @@ -273,13 +274,7 @@ export default class Problem extends Component {

const speechForMath = (this.props.problem && this.props.problem.text) ? (
<span className="sROnly">
{mathLive.latexToSpeakableText(
this.props.problem.text,
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
)}
{latexToSpeakableText(this.props.problem.text)}
</span>
) : null;

Expand Down
17 changes: 3 additions & 14 deletions src/components/Home/components/NewProblemsForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import scrollTo from '../../../../scripts/scrollTo';
import googleAnalytics from '../../../../scripts/googleAnalytics';
import { passEventForKeys, stopEvent } from '../../../../services/events';
import TTSButton from '../../../TTSButton';
import { latexToSpeakableText } from '../../../../services/speech';

const mathLive = process.env.MATHLIVE_DEBUG_MODE ? require('../../../../../../mathlive/src/mathlive.js').default
: require('../../../../lib/mathlivedist/mathlive.js');
Expand Down Expand Up @@ -125,13 +126,7 @@ export default class NewProblemsForm extends Component {
getSpeakableTextForStep = (stepNo, problem) => (
Locales.strings.step_tts_text
.replace('{stepNo}', stepNo)
.replace('{mathEquation}', mathLive.latexToSpeakableText(
problem.text,
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
))
.replace('{mathEquation}', latexToSpeakableText(problem.text))
.replace('{explanation}', problem.title)
);

Expand All @@ -140,13 +135,7 @@ export default class NewProblemsForm extends Component {
if (this.props.theActiveMathField) {
math = this.props.theActiveMathField.$latex();
if (math) {
math = mathLive.latexToSpeakableText(
math,
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'clearspeak', style: 'default', markup: 'none' },
},
);
math = latexToSpeakableText(math);
}
}
return [math, this.props.textAreaValue].filter(val => val.trim() !== '').join(' .');
Expand Down
14 changes: 14 additions & 0 deletions src/services/speech.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const mathLive = process.env.MATHLIVE_DEBUG_MODE ? require('../../../mathlive/src/mathlive.js').default
: require('../lib/mathlivedist/mathlive.js');

export const latexToSpeakableText = latex => mathLive.latexToSpeakableText(
latex.replace(/updiagonalstrike downdiagonalstrike/g, 'updiagonalstrike'),
{
textToSpeechRules: 'sre',
textToSpeechRulesOptions: { domain: 'mathspeak', style: 'default', markup: 'none' },
},
);

export default {
latexToSpeakableText,
};

0 comments on commit 5dbb258

Please sign in to comment.