Skip to content

Commit e3e0b28

Browse files
committed
Plugin: Text2Speech: Don't integrate directly with AIHelper plugin - refs #4622
1 parent d6fd27e commit e3e0b28

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

plugin/ai_helper/tool/learnpath.php

+2-14
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99

1010
require_once __DIR__.'/../../../main/inc/global.inc.php';
1111
require_once __DIR__.'/../AiHelperPlugin.php';
12-
require_once __DIR__.'/../../text2speech/Text2SpeechPlugin.php';
1312
require_once api_get_path(SYS_CODE_PATH).'exercise/export/aiken/aiken_classes.php';
1413
require_once api_get_path(SYS_CODE_PATH).'exercise/export/aiken/aiken_import.inc.php';
1514

16-
$text2speechPlugin = Text2SpeechPlugin::create();
17-
$isTextToSpeechEnabled = $text2speechPlugin->get('tool_enable') && $text2speechPlugin->get('tool_lp_enable');
18-
1915
$plugin = AiHelperPlugin::create();
2016

2117
$apiList = $plugin->getApiList();
@@ -70,19 +66,11 @@
7066
$promptItem = sprintf($messageGetItemContent, $topic, $courseLanguage, $wordsCount, $title);
7167
$resultContentText = $plugin->openAiGetCompletionText($promptItem, 'learnpath');
7268
$lpItemContent = (!empty($resultContentText) ? trim($resultContentText) : '');
73-
$audioControl = '';
74-
if ($isTextToSpeechEnabled && !empty($lpItemContent)) {
75-
$filePath = $text2speechPlugin->convert(strip_tags($lpItemContent));
76-
$audioControl = '<audio controls>'.
77-
'<source src="'.$filePath.'" type="audio/ogg">'.
78-
'Your browser does not support the audio element.'.
79-
'</audio>';
80-
}
8169

8270
if (false !== stripos($lpItemContent, '</head>')) {
83-
$lpItemContent = preg_replace("|</head>|i", "\r\n$style\r\n\\0", $audioControl.$lpItemContent);
71+
$lpItemContent = preg_replace("|</head>|i", "\r\n$style\r\n\\0", $lpItemContent);
8472
} else {
85-
$lpItemContent = '<html><head><title>'.trim($title).'</title>'.$style.'</head><body>'.$audioControl.$lpItemContent.'</body></html>';
73+
$lpItemContent = '<html><head><title>'.trim($title).'</title>'.$style.'</head><body>'.$lpItemContent.'</body></html>';
8674
}
8775
$lpItems[$position]['content'] = $lpItemContent;
8876
$position++;

0 commit comments

Comments
 (0)