Skip to content

Commit 21f372d

Browse files
committed
limit bounds for speed in openai api
Signed-off-by: Lukas Schaefer <[email protected]>
1 parent bcb6258 commit 21f372d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/TaskProcessing/TextToSpeechProvider.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public function getOptionalInputShape(): array {
7575
),
7676
'speed' => new ShapeDescriptor(
7777
$this->l->t('Speed'),
78-
$this->l->t('Speech speed modifier'),
78+
$this->openAiAPIService->isUsingOpenAi() ?
79+
$this->l->t('Speech speed modifier (Valid values: 0.25-4)')
80+
: $this->l->t('Speech speed modifier'),
7981
EShapeType::Number
8082
)
8183
];
@@ -134,6 +136,13 @@ public function process(?string $userId, array $input, callable $reportProgress)
134136
$speed = 1;
135137
if (isset($input['speed']) && is_numeric($input['speed'])) {
136138
$speed = $input['speed'];
139+
if ($this->openAiAPIService->isUsingOpenAi()) {
140+
if ($speed > 4) {
141+
$speed = 4;
142+
} elseif ($speed < 0.25) {
143+
$speed = 0.25;
144+
}
145+
}
137146
}
138147

139148
try {

0 commit comments

Comments
 (0)