Skip to content

Commit db00b15

Browse files
committed
feat: TTS 사용 여부 체크
1 parent e850d63 commit db00b15

File tree

4 files changed

+19
-23
lines changed

4 files changed

+19
-23
lines changed

ProjectVG.Api/Controllers/ChatController.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Microsoft.AspNetCore.Mvc;
2-
using Microsoft.AspNetCore.Authorization;
32
using ProjectVG.Application.Models.Chat;
43
using ProjectVG.Application.Models.API.Request;
54
using ProjectVG.Application.Services.Chat;
@@ -31,8 +30,9 @@ public async Task<IActionResult> ProcessChat([FromBody] ChatRequest request)
3130
var command = new ChatRequestCommand(
3231
userGuid,
3332
request.CharacterId,
34-
request.Message,
35-
DateTime.UtcNow);
33+
request.Message,
34+
DateTime.UtcNow,
35+
request.UseTTS);
3636

3737
var result = await _chatService.EnqueueChatRequestAsync(command);
3838

ProjectVG.Api/Models/Chat/Request/ChatRequest.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ namespace ProjectVG.Application.Models.API.Request
55
{
66
public class ChatRequest
77
{
8-
[JsonPropertyName("session_id")]
9-
public string SessionId { get; set; } = string.Empty;
10-
118
[JsonPropertyName("message")]
129
public string Message { get; set; } = string.Empty;
1310

ProjectVG.Application/Models/Chat/ChatRequestCommand.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ public ChatRequestCommand()
3030
ProcessAt = DateTime.UtcNow;
3131
}
3232

33-
public ChatRequestCommand(Guid userId, Guid characterId, string userPrompt, DateTime requestedAt)
33+
public ChatRequestCommand(Guid userId, Guid characterId, string userPrompt, DateTime requestedAt, bool useTTS)
3434
{
3535
Id = Guid.NewGuid();
3636
UserId = userId;
3737
CharacterId = characterId;
3838
UserPrompt = userPrompt;
3939
UserRequestAt = requestedAt;
4040
ProcessAt = DateTime.UtcNow;
41+
UseTTS = useTTS;
4142
}
4243

4344
public void SetConversationHistory(IEnumerable<ConversationHistory> histories)

test-clients/test-client.html

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@
187187

188188
<div id="chat-log"></div>
189189

190+
<div id="audio-option-row" style="display: flex; align-items: center; gap: 1em; margin-bottom: 0.5em;">
191+
<label style="display: flex; align-items: center; gap: 0.5em; cursor: pointer; color: #37474f;">
192+
<input id="include-audio" type="checkbox" checked style="cursor: pointer;" />
193+
<span>음성 포함</span>
194+
</label>
195+
</div>
196+
190197
<div id="input-row">
191198
<input id="user-input" type="text" placeholder="메시지를 입력하세요" autocomplete="off" />
192199
<button id="send-btn">전송</button>
@@ -233,6 +240,7 @@
233240
const guestIdInput = document.getElementById('guest-id');
234241
const loginBtn = document.getElementById('login-btn');
235242
const loginSection = document.getElementById('login-section');
243+
const includeAudioCheckbox = document.getElementById('include-audio');
236244

237245
const audioQueue = [];
238246
let isPlayingAudio = false;
@@ -272,8 +280,7 @@
272280
headers: {
273281
'Content-Type': 'application/json'
274282
},
275-
body: JSON.stringify(guestId) // 문자열로 직접 전송
276-
// body: JSON.stringify({ guestId: guestId }) // JSON 객체로 전송 (Controller 수정 시)
283+
body: JSON.stringify(guestId)
277284
});
278285

279286
if (response.ok) {
@@ -321,17 +328,10 @@
321328
const messageType = dataView.getUint8(offset);
322329
offset += 1;
323330

324-
if (messageType !== 0x03) { // MESSAGE_TYPE_INTEGRATED
325-
return null; // 지원하지 않는 메시지 타입
331+
if (messageType !== 0x03) {
332+
return null;
326333
}
327334

328-
// 세션 ID 읽기
329-
const sessionIdLength = dataView.getUint32(offset, true); // little-endian
330-
offset += 4;
331-
const sessionIdBytes = new Uint8Array(arrayBuffer, offset, sessionIdLength);
332-
const sessionId = new TextDecoder().decode(sessionIdBytes);
333-
offset += sessionIdLength;
334-
335335
// 텍스트 읽기
336336
const textLength = dataView.getUint32(offset, true);
337337
offset += 4;
@@ -668,13 +668,14 @@
668668
userInput.value = "";
669669

670670
const payload = {
671-
actor: "web_user",
672671
message: msg,
673672
action: "chat",
674673
character_id: characterSelect.value,
675-
user_id: userId || "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
674+
use_tts: includeAudioCheckbox.checked
676675
};
677676

677+
console.log(includeAudioCheckbox.checked)
678+
678679
const headers = { "Content-Type": "application/json" };
679680
if (authToken) {
680681
headers["Authorization"] = `Bearer ${authToken}`;
@@ -692,9 +693,6 @@
692693
}
693694
return res.json();
694695
})
695-
.then(data => {
696-
// sessionId 로직 제거 - 응답 처리는 WebSocket을 통해
697-
})
698696
.catch(err => {
699697
appendLog(`<span style='color:red'>[HTTP 오류] ${err}</span>`);
700698
console.error(err);

0 commit comments

Comments
 (0)