File size: 5,799 Bytes
ae238b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import React, { useState } from 'react';
import { formatTime } from '../utils/subtitleUtils';
import { useTranscriptionStore } from '../stores/transcriptionStore';
import { InformationCircleIcon } from '@heroicons/react/24/outline';

const FullTranscription: React.FC = () => {
  const [showInfoTooltip, setShowInfoTooltip] = useState(false);
  const [showExpandedChunks, setShowExpandedChunks] = useState(false);
  const { transcription, selectedLanguage } = useTranscriptionStore();

  const renderInfoTooltip = () => {
    if (!transcription) return null;

    const chunks = transcription.chunks || [];
    const maxVisibleChunks = 3;
    const hasMoreChunks = chunks.length > maxVisibleChunks;
    const visibleChunks = showExpandedChunks ? chunks : chunks.slice(0, maxVisibleChunks);

    // Calculate better positioning to avoid edge cuts
    const tooltipStyle: React.CSSProperties = {
      position: 'fixed',
      left: '50%',
      top: '50%',
      transform: 'translate(-50%, -50%)',
      maxHeight: '80vh',  // Prevent tooltip from being taller than viewport
      overflowY: 'auto' as const
    };

    return (
      <div
        className="z-50 p-3 bg-gray-900 text-white text-xs rounded-lg shadow-xl border border-gray-600 min-w-64 max-w-96"
        style={tooltipStyle}>

        <div className="font-semibold mb-2 text-blue-300">Transcription Details</div>

        <div className="space-y-1">
          <div className="flex justify-between">
            <span className="text-gray-300">Model:</span>
            <span>{transcription.model}</span>
          </div>

          <div className="flex justify-between">
            <span className="text-gray-300">Language:</span>
            <span className="font-mono">
              {selectedLanguage || 'auto-detect'}
            </span>
          </div>

          <div className="flex justify-between">
            <span className="text-gray-300">Segments:</span>
            <span>{transcription.num_segments}</span>
          </div>

          <div className="flex justify-between">
            <span className="text-gray-300">Duration:</span>
            <span>{formatTime(transcription.total_duration)}</span>
          </div>

          <div className="flex justify-between">
            <span className="text-gray-300">Device:</span>
            <span className="font-mono">{transcription.device}</span>
          </div>

          {/* Long-form specific info */}
          {transcription.num_chunks && (
            <>
              <div className="border-t border-gray-600 pt-1 mt-1">
                <div className="text-xs text-blue-300 font-semibold mb-1">Long-form Processing</div>
              </div>
              <div className="flex justify-between">
                <span className="text-gray-300">Chunks:</span>
                <span>{transcription.num_chunks}</span>
              </div>
            </>
          )}
        </div>

        {/* Improved Chunk details */}
        {chunks.length > 0 && (
          <div className="mt-2">
            <div className="flex items-center justify-between mb-1">
              <div className="text-xs text-blue-300 font-semibold">Chunk Details</div>
              {hasMoreChunks && (
                <button
                  onClick={() => setShowExpandedChunks(!showExpandedChunks)}
                  className="text-xs text-blue-400 hover:text-blue-300 underline transition-colors"
                >
                  {showExpandedChunks ? 'Show Less' : `Show All (${chunks.length})`}
                </button>
              )}
            </div>

            <div className="space-y-1 max-h-48 overflow-y-auto">
              {visibleChunks.map((chunk, index) => (
                <div key={index} className="text-xs bg-gray-700 p-2 rounded border border-gray-600">
                  <div className="flex justify-between items-start">
                    <div className="font-medium text-gray-200">
                      Chunk #{index + 1}
                    </div>
                    <div className="text-gray-400 text-xs">
                      {chunk.duration.toFixed(1)}s
                    </div>
                  </div>
                  <div className="text-gray-300 font-mono mt-1">
                    {formatTime(chunk.start_time)} → {formatTime(chunk.end_time)}
                  </div>
                </div>
              ))}

              {hasMoreChunks && !showExpandedChunks && (
                <div className="text-center py-1">
                  <button
                    onClick={() => setShowExpandedChunks(true)}
                    className="text-xs text-blue-400 hover:text-blue-300 underline transition-colors"
                  >
                    +{chunks.length - maxVisibleChunks} more chunks...
                  </button>
                </div>
              )}
            </div>
          </div>
        )}
      </div>
    );
  };

  if (!transcription) return null;

  return (
    <div className="p-4 bg-gray-800 border-t border-gray-700">
      <div className="flex items-center gap-2 mb-3">
        <h3 className="text-sm font-semibold text-white">Full Transcription</h3>

        {/* Info tooltip */}
        <div className="relative">
          <InformationCircleIcon
            className="w-4 h-4 text-gray-400 hover:text-gray-200 cursor-help transition-colors"
            onMouseEnter={() => setShowInfoTooltip(true)}
            onMouseLeave={() => setShowInfoTooltip(false)}
          />
          {showInfoTooltip && renderInfoTooltip()}
        </div>
      </div>

      <div className="text-sm max-h-32 overflow-y-auto text-gray-300 font-mono bg-gray-900 p-3 rounded border border-gray-600">
        {transcription.transcription}
      </div>
    </div>
  );
};

export default FullTranscription;