fix: audio speech to text nodjs code
This commit is contained in:
@@ -16,13 +16,6 @@ export const ollamaModelOptions = [
|
||||
id: 'qwen2.5-coder',
|
||||
tags: []
|
||||
},
|
||||
{
|
||||
label: 'llama3.2-vision',
|
||||
value: 'llama3.2-vision',
|
||||
name: 'llama3.2-vision',
|
||||
id: 'llama3.2-vision',
|
||||
tags: []
|
||||
},
|
||||
{
|
||||
label: 'llama3.2',
|
||||
value: 'llama3.2',
|
||||
|
||||
@@ -80,12 +80,16 @@ const ViewCodeModal: React.FC<ViewModalProps> = (props) => {
|
||||
null,
|
||||
4
|
||||
);
|
||||
const headers = {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
Authorization: `Bearer {YOUR_GPUSTACK_API_KEY}`
|
||||
};
|
||||
const params = paramStr.replace(
|
||||
/"fs.createReadStream\(audio.mp3\)"/g,
|
||||
'fs.createReadStream("audio.mp3")'
|
||||
);
|
||||
|
||||
const code = `const fs = require("fs")\nconst OpenAI = require("openai");\n\nconst openai = new OpenAI({\n "apiKey": "YOUR_GPUSTACK_API_KEY",\n "baseURL": "${BaseURL}"\n});\n\nasync function main(){\n const params = ${params};\nconst response = await openai.${clientType}(params);\n ${consoleLog}}\nmain();`;
|
||||
const code = `const fs = require("fs");\nconst axios = require("axios");\n\nconst url = "${BaseURL}/audio/transcriptions";\n\nconst headers = ${JSON.stringify(headers, null, 2)};\n\nconst data = ${params};\n\naxios.post(url, data, { headers }).then((response) => {\n console.log(response.data.text);\n});`;
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user