MCPcopy
hub / github.com/modstart-lib/aigcpanel / serverSoundGenerate

Function serverSoundGenerate

src/lib/server.ts:110–193  ·  view source on GitHub ↗
(
    biz: TaskBiz,
    bizId: string,
    soundGenerate: SoundGenerateParamType,
    result: {},
    text: string,
    option?: ServerCallOptionType,
)

Source from the content-addressed store, hash-verified

108};
109
110export const serverSoundGenerate = async (
111 biz: TaskBiz,
112 bizId: string,
113 soundGenerate: SoundGenerateParamType,
114 result: {},
115 text: string,
116 option?: ServerCallOptionType,
117): Promise<{
118 type: string;
119 start: number;
120 end: number;
121 url: string;
122}> => {
123 text = await replaceSoundGenerateText(text);
124 option = Object.assign(
125 {
126 cache: true,
127 },
128 option,
129 ) as ServerCallOptionType;
130 if (option.cache) {
131 const cacheUrl = await $mapi.file.cacheGetPath({ soundGenerate, text });
132 if (cacheUrl) {
133 return {
134 type: "success",
135 start: 0,
136 end: 0,
137 url: cacheUrl,
138 };
139 }
140 }
141 const server = await serverStore.getByNameVersion(
142 soundGenerate.serverName,
143 soundGenerate.serverVersion,
144 );
145 if (!server) {
146 throw "SoundGenerate server not found: " + soundGenerate.serverName;
147 }
148 const serverInfo = await serverStore.serverInfo(server);
149 let res;
150 if (soundGenerate.type == "SoundTts") {
151 res = await serverStore.call(serverInfo, "soundTts", {
152 id: serverStore.generateTaskId(biz, bizId),
153 result: result,
154 param: soundGenerate.ttsParam,
155 text: text,
156 });
157 } else if (soundGenerate.type == "SoundClone") {
158 res = await serverStore.call(serverInfo, "soundClone", {
159 id: serverStore.generateTaskId(biz, bizId),
160 result: result,
161 param: soundGenerate.cloneParam,
162 text: text,
163 promptAudio: soundGenerate.promptUrl,
164 promptText: soundGenerate.promptText,
165 });
166 } else {
167 throw `SoundGenerate.error - type error ${soundGenerate.type}`;

Callers 3

task.tsFile · 0.90
task.tsFile · 0.90
task.tsFile · 0.90

Calls 2

tFunction · 0.90
replaceSoundGenerateTextFunction · 0.85

Tested by

no test coverage detected