ReviewOS

also looking at this

meemalabs/laravel-text-to-speech

Apply fixes from StyleCI

#11
Merged luigel wants to merge analysis-ka7DZJ into master
2 files +12 -18
src/Converters/PollyConverter.phpmodified+11-17
Changes to src/Converters/PollyConverter.php
@@ -51,15 +51,13 @@ class PollyConverter implements Converter
5151 {
5252 $text = $this->getTextFromSource($data);
5353
54 if ($this->isTextAboveLimit($text))
55 {
54 if ($this->isTextAboveLimit($text)) {
5655 $text = $this->getChunkText($text);
5756 }
5857
5958 $result = $this->synthesizeSpeech($text, $options);
6059
61 if ($result instanceof Result)
62 {
60 if ($result instanceof Result) {
6361 // Store audio file to disk
6462 return $this->store(
6563 $this->getTextFromSource($data),
formatting only · 7 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -71,7 +69,6 @@ class PollyConverter implements Converter formatting only
7169 $this->getTextFromSource($data),
7270 $this->mergeOutputs($result)
7371 );
74
7572 }
7673
7774 /**
Changes to src/Converters/PollyConverter.php
@@ -83,20 +80,18 @@ class PollyConverter implements Converter
8380 */
8481 protected function synthesizeSpeech($text, array $options = null)
8582 {
86 if (is_string($text))
87 {
83 if (is_string($text)) {
8884 return $this->client->synthesizeSpeech([
8985 'VoiceId' => $this->voice($options),
9086 'OutputFormat' => $this->format($options),
9187 'TextType' => 'ssml',
92 'Text' => '<speak>' . $text . '</speak>',
88 'Text' => '<speak>'.$text.'</speak>',
9389 ]);
9490 }
9591
9692 $results = [];
9793
98 foreach ($text as $item)
99 {
94 foreach ($text as $item) {
10095 $result = $this->client->synthesizeSpeech([
10196 'VoiceId' => $this->voice($options),
10297 'OutputFormat' => $this->format($options),
@@ -110,15 +105,14 @@ class PollyConverter implements Converter
110105 }
111106
112107 /**
113 * Merges the output from amazon polly
108 * Merges the output from amazon polly.
114109 *
115110 * @return mixed
116111 */
117112 protected function mergeOutputs(array $results)
118113 {
119114 $mergedResult = null;
120 foreach ($results as $result)
121 {
115 foreach ($results as $result) {
122116 $mergedResult .= $this->getResultContent($result);
123117 }
124118
@@ -126,10 +120,10 @@ class PollyConverter implements Converter
126120 }
127121
128122 /**
129 * Checks the length of the text if more than 3000
123 * Checks the length of the text if more than 3000.
130124 *
131125 * @param string $text
132 * @return boolean
126 * @return bool
133127 */
134128 protected function isTextAboveLimit(string $text)
135129 {
@@ -137,7 +131,7 @@ class PollyConverter implements Converter
137131 }
138132
139133 /**
140 * Chunk the given text into array
134 * Chunk the given text into array.
141135 *
142136 * @param string $text
143137 * @param int $size
formatting only · 8 hidden lines
Changes to src/Converters/PollyConverter.php
@@ -145,7 +139,7 @@ class PollyConverter implements Converter formatting only
145139 */
146140 protected function getChunkText(string $text, int $size = 2000)
147141 {
148 return explode( "\n", wordwrap($text, $size));
142 return explode("\n", wordwrap($text, $size));
149143 }
150144
151145 /**
src/Sources/WebsiteSource.phpmodifiedformatting only+1-1
Changes to src/Sources/WebsiteSource.php
@@ -64,7 +64,7 @@ class WebsiteSource implements SourceContract
6464 );
6565 foreach ($dit as $node) {
6666 if ($node->nodeName === 'p') {
67 $text .= $node->textContent . ' ';
67 $text .= $node->textContent.' ';
6868 }
6969 }
7070 }