Skip to content

Commit

Permalink
Merge pull request #298 from tmddus2/fix/231213-fix-api
Browse files Browse the repository at this point in the history
Feat: CLOVA ์žฅ๋ฌธ ์Œ์„ฑ์ถ”์ถœ API ํ˜ธ์ถœ
  • Loading branch information
platinouss authored Dec 13, 2023
2 parents 5897f36 + bc56496 commit 7062307
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions mediaServer/src/utils/MediaConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class MediaConverter {
requestToServer = async (roomId: string) => {
// TODO: API ์„œ๋ฒ„์— ๊ฐ•์˜ ์ข…๋ฃŒ ์š”์ฒญํ•˜๊ธฐ
const url = await this.saveAudioFile(roomId);
await this.extractSubtitle(url, roomId);
fetch((process.env.SERVER_API_URL + '/lecture/end') as string, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
Expand All @@ -116,6 +117,24 @@ class MediaConverter {
})
}).then((response) => console.log(`[${response.status}]๊ฐ•์˜ ์Œ์„ฑ ํŒŒ์ผ ์ €์žฅ: ${url}`));
};

extractSubtitle = async (url: any, code: string) => {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('X-CLOVASPEECH-API-KEY', process.env.CLOVA_API_KEY as string);

const response = await fetch(process.env.CLOVA_API_URL as string, {
method: 'POST',
headers: headers,
body: JSON.stringify({
language: process.env.CLOVA_API_LANGUAGE,
completion: process.env.CLOVA_API_COMPLETION,
url: url,
callback: `${process.env.SERVER_API_URL}/lecture/${code}/text`
})
});
console.log(`[${response.status}] ๊ฐ•์˜ ์ž๋ง‰ ์ €์žฅ`);
};
}

const outputDir = path.join(process.cwd(), 'output');
Expand Down

0 comments on commit 7062307

Please sign in to comment.