Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from n33kos/speakText
Add speakText
- Loading branch information
Showing
5 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { speakText } from '../../src/actions'; | ||
|
||
describe('speakText function', () => { | ||
it('is a function', () => { | ||
expect(typeof speakText).toBe('function'); | ||
}); | ||
|
||
it('builds a speakText action when no parameters are passed', () => { | ||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.speaktext', | ||
WFWorkflowActionParameters: { | ||
WFSpeakTextLanguage: 'Default', | ||
WFSpeakTextPitch: 1.0, | ||
WFSpeakTextRate: 0.5, | ||
WFSpeakTextVoice: 'Default', | ||
WFSpeakTextWait: true, | ||
}, | ||
}; | ||
const actual = speakText({}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
|
||
it('builds a text action when parameters are passed', () => { | ||
const testLanguage = 'English'; | ||
const testPitch = 0.75; | ||
const testRate = 0.5; | ||
const testVoice = 'Irish'; | ||
const testWaitUntilFinished = false; | ||
|
||
const expected = { | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.speaktext', | ||
WFWorkflowActionParameters: { | ||
WFSpeakTextLanguage: testLanguage, | ||
WFSpeakTextPitch: testPitch, | ||
WFSpeakTextRate: testRate, | ||
WFSpeakTextVoice: testVoice, | ||
WFSpeakTextWait: testWaitUntilFinished, | ||
}, | ||
}; | ||
const actual = speakText({ | ||
language: 'English', | ||
pitch: 0.75, | ||
rate: 0.5, | ||
voice: 'Irish', | ||
waitUntilFinished: false, | ||
}); | ||
|
||
expect(actual).toEqual(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import WFWorkflowAction from '../interfaces/WF/WFWorkflowAction'; | ||
|
||
/** | ||
* @action Speak Text | ||
* @section Content Types > Documents > Speak Text | ||
* @icon Documents | ||
* | ||
* Speaks the inputted text aloud. | ||
* | ||
* ```js | ||
* speakText({ | ||
* language: 'Default', | ||
* pitch: 1.0, | ||
* rate: 0, | ||
* voice: 'Default', | ||
* waitUntilFinished: true, | ||
* }); | ||
* ``` | ||
*/ | ||
|
||
const speakText = ( | ||
{ | ||
language = 'Default', | ||
pitch = 1.0, | ||
rate = 0.5, | ||
voice = 'Default', | ||
waitUntilFinished = true, | ||
}: { | ||
/** The language to use when speaking text */ | ||
language?: string, | ||
/** The pitch to use when speaking text */ | ||
pitch?: number | ||
/** The rate to use when speaking text */ | ||
rate?: number | ||
/** The voice to use when speaking text */ | ||
voice?: string, | ||
/** Should we wait until the speaking is finished to run the next action */ | ||
waitUntilFinished?: boolean, | ||
}, | ||
): WFWorkflowAction => ({ | ||
WFWorkflowActionIdentifier: 'is.workflow.actions.speaktext', | ||
WFWorkflowActionParameters: { | ||
WFSpeakTextLanguage: language, | ||
WFSpeakTextPitch: pitch, | ||
WFSpeakTextRate: rate, | ||
WFSpeakTextVoice: voice, | ||
WFSpeakTextWait: waitUntilFinished, | ||
}, | ||
}); | ||
|
||
export default speakText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters