|
|
@@ -2548,8 +2548,15 @@ function handleEpisodeContent($originalContent) {
|
|
|
$description = trim($charMatch[2]);
|
|
|
$timbreName = null;
|
|
|
|
|
|
- // 检查描述末尾是否有{{音色名}}格式
|
|
|
- if (preg_match('/^(.*?)\{\{([^}]+)\}\}\s*$/u', $description, $timbreMatch)) {
|
|
|
+ // 检查描述末尾是否有{主体图片提示词}{{音色名}}格式
|
|
|
+ $picPrompt = null;
|
|
|
+ if (preg_match('/^(.*?)\{([^}]+)\}\{\{([^}]+)\}\}\s*$/u', $description, $fullMatch)) {
|
|
|
+ // 匹配格式:主体描述{主体图片提示词}{{音色名}}
|
|
|
+ $description = trim($fullMatch[1]);
|
|
|
+ $picPrompt = trim($fullMatch[2]);
|
|
|
+ $timbreName = trim($fullMatch[3]);
|
|
|
+ } elseif (preg_match('/^(.*?)\{\{([^}]+)\}\}\s*$/u', $description, $timbreMatch)) {
|
|
|
+ // 兼容旧格式:主体描述{{音色名}}
|
|
|
$description = trim($timbreMatch[1]);
|
|
|
$timbreName = trim($timbreMatch[2]);
|
|
|
}
|
|
|
@@ -2559,6 +2566,11 @@ function handleEpisodeContent($originalContent) {
|
|
|
'description' => $description
|
|
|
];
|
|
|
|
|
|
+ // 如果有主体图片提示词,添加到数组中
|
|
|
+ if ($picPrompt) {
|
|
|
+ $roleData['pic_prompt'] = $picPrompt;
|
|
|
+ }
|
|
|
+
|
|
|
// 如果有音色信息,添加到数组中
|
|
|
if ($timbreName) {
|
|
|
$timbre = DB::table('mp_timbres')->where('is_enabled', 1)->where('timbre_name', 'like', "%{$timbreName}%")->orderBy('id')->select('timbre_type', 'audio_url')->first();
|
|
|
@@ -2585,6 +2597,7 @@ function handleEpisodeContent($originalContent) {
|
|
|
$result['roles'][] = [
|
|
|
'role' => '旁白',
|
|
|
'description' => '负责叙述剧情、补充说明和情感渲染的非视觉角色。',
|
|
|
+ 'pic_prompt' => '',
|
|
|
'voice_name' => '旁白',
|
|
|
'voice_type' => 'zh_male_linjiananhai_moon_bigtts',
|
|
|
'voice_audio_url' => 'https://zw-audiobook.tos-cn-beijing.volces.com/demonstrate/zh_male_linjiananhai_moon_bigtts.wav'
|
|
|
@@ -3109,7 +3122,15 @@ function parseRolesFromText(string $rolesText): array
|
|
|
$description = trim($charMatch[2]);
|
|
|
$timbreName = null;
|
|
|
|
|
|
- if (preg_match('/^(.*?)\{\{([^}]+)\}\}\s*$/u', $description, $timbreMatch)) {
|
|
|
+ // 检查描述末尾是否有{主体图片提示词}{{音色名}}格式
|
|
|
+ $picPrompt = null;
|
|
|
+ if (preg_match('/^(.*?)\{([^}]+)\}\{\{([^}]+)\}\}\s*$/u', $description, $fullMatch)) {
|
|
|
+ // 匹配格式:主体描述{主体图片提示词}{{音色名}}
|
|
|
+ $description = trim($fullMatch[1]);
|
|
|
+ $picPrompt = trim($fullMatch[2]);
|
|
|
+ $timbreName = trim($fullMatch[3]);
|
|
|
+ } elseif (preg_match('/^(.*?)\{\{([^}]+)\}\}\s*$/u', $description, $timbreMatch)) {
|
|
|
+ // 兼容旧格式:主体描述{{音色名}}
|
|
|
$description = trim($timbreMatch[1]);
|
|
|
$timbreName = trim($timbreMatch[2]);
|
|
|
}
|
|
|
@@ -3119,6 +3140,11 @@ function parseRolesFromText(string $rolesText): array
|
|
|
'description' => $description,
|
|
|
];
|
|
|
|
|
|
+ // 如果有主体图片提示词,添加到数组中
|
|
|
+ if ($picPrompt) {
|
|
|
+ $roleData['pic_prompt'] = $picPrompt;
|
|
|
+ }
|
|
|
+
|
|
|
if ($timbreName) {
|
|
|
$timbre = DB::table('mp_timbres')
|
|
|
->where('is_enabled', 1)
|
|
|
@@ -3150,6 +3176,7 @@ function parseRolesFromText(string $rolesText): array
|
|
|
$roles[] = [
|
|
|
'role' => '旁白',
|
|
|
'description' => '负责叙述剧情、补充说明和情感渲染的非视觉角色。',
|
|
|
+ 'pic_prompt' => '',
|
|
|
'voice_name' => '旁白',
|
|
|
'voice_type' => 'zh_male_linjiananhai_moon_bigtts',
|
|
|
'voice_audio_url' => 'https://zw-audiobook.tos-cn-beijing.volces.com/demonstrate/zh_male_linjiananhai_moon_bigtts.wav'
|