ReviewOS

also looking at this

meemalabs/laravel-text-to-speech

Added support for speech marks.

#26
Merged luigel wants to merge feature/add-support-for-speech-marks into main
7 files +125 -19

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

config/config.phpmodified+8-0
Changes to config/config.php
@@ -82,6 +82,14 @@ return [
8282 */
8383 'voice_id' => env('AWS_VOICE_ID', 'Amy'),
8484
85 /**
86 * You can request any or all of the speech mark types, but leave it empty if you don't use speech marks.
87 * You may add any of the following:.
88 *
89 * sentence, word, viseme, ssml
90 */
91 'speech_marks' => [],
92
8593 /**
8694 * IAM Credentials from AWS.
8795 */
src/Converters/PollyConverter.phpmodified+16-2
Changes to src/Converters/PollyConverter.php
@@ -87,12 +87,14 @@ class PollyConverter implements Converter
8787 */
8888 protected function synthesizeSpeech($text, array $options = null)
8989 {
90 $speechMarks = $this->getSpeechMarks();
91
9092 $arguments = [
9193 'LanguageCode' => $this->getLanguage(),
9294 'VoiceId' => $this->voice($options),
9395 'OutputFormat' => $this->format($options),
9496 'TextType' => $this->textType(),
95 'SpeechMarkTypes' => $this->speechMarks,
97 'SpeechMarkTypes' => $speechMarks,
9698 ];
9799
98100 if (is_string($text)) {
@@ -204,6 +206,18 @@ class PollyConverter implements Converter
204206 return Arr::get($options, 'format', $default);
205207 }
206208
209 /**
210 * Get the speech marks.
211 *
212 * @return array
213 */
214 protected function getSpeechMarks()
215 {
216 $default = config('tts.services.polly.speech_marks', []);
217
218 return ! empty($this->speechMarks) ? $this->speechMarks : $default;
219 }
220
207221 /**
208222 * Get the content of the result from AWS Polly.
209223 *
@@ -222,7 +236,7 @@ class PollyConverter implements Converter
222236 */
223237 protected function hasSpeechMarks()
224238 {
225 return ! empty($this->speechMarks);
239 return ! empty($this->getSpeechMarks());
226240 }
227241
228242 /**