File size: 2,247 Bytes
3a495d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="ja" class="dark">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>会話詳細画面</title>
    <script src="https://cdn.tailwindcss.com"></script>
  </head>
  <body
    class="bg-gray-100 dark:bg-gray-900 text-gray-900 dark:text-gray-100 min-h-screen flex items-center justify-center"
  >
    <div
      class="container mx-auto p-6 bg-white dark:bg-gray-800 shadow-lg rounded-2xl"
    >
      <h2 class="text-2xl font-semibold mb-4">会話の文字起こし表示</h2>
      <div
        id="transcription"
        class="p-4 bg-gray-200 dark:bg-gray-700 rounded-lg mb-4 max-h-96 overflow-y-auto"
      >
        ここに会話内容が表示されます。
      </div>
      <div class="flex justify-center gap-4">
        <button
          class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
          onclick="showRecorder()"
        >
          録音画面を表示
        </button>
        <button
          class="px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 transition-colors"
          onclick="showFeedback()"
        >
          フィードバック画面を表示
        </button>
      </div>
    </div>
    <script>
      async function displayTranscription() {
        const transcriptionElement = document.getElementById("transcription");

        try {
          const response = await fetch("/api/transcription");
          if (!response.ok) throw new Error("データ取得に失敗しました。");

          const data = await response.json();
          const formattedText = data.conversations
            .map((conv) => `【${conv.speaker}${conv.text}`)
            .join("\n");

          transcriptionElement.textContent = formattedText;
        } catch (error) {
          transcriptionElement.textContent = `エラー: ${error.message}`;
          console.error("データ取得エラー:", error);
        }
      }

      displayTranscription();

      function showRecorder() {
        window.location.href = "/index";
      }

      function showFeedback() {
        window.location.href = "/feedback";
      }
    </script>
  </body>
</html>