From bc56496c0086c14ab70525be0dd1e52e9bc29240 Mon Sep 17 00:00:00 2001 From: tmddus2 Date: Thu, 14 Dec 2023 00:03:23 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20CLOVA=20=EC=9E=A5=EB=AC=B8=20=EC=9D=8C?= =?UTF-8?q?=EC=84=B1=EC=B6=94=EC=B6=9C=20API=20=ED=98=B8=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mediaServer/src/utils/MediaConverter.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mediaServer/src/utils/MediaConverter.ts b/mediaServer/src/utils/MediaConverter.ts index 9bab492..9b82e40 100644 --- a/mediaServer/src/utils/MediaConverter.ts +++ b/mediaServer/src/utils/MediaConverter.ts @@ -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' }, @@ -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');