ciyidogan commited on
Commit
35b2ee3
·
verified ·
1 Parent(s): e5e4952

Create realtime-chat.component.html

Browse files
flare-ui/src/app/components/chat/realtime-chat.component.html ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <mat-card class="realtime-chat-container">
2
+ <mat-card-header>
3
+ <mat-icon mat-card-avatar>voice_chat</mat-icon>
4
+ <mat-card-title>Real-time Conversation</mat-card-title>
5
+ <mat-card-subtitle>
6
+ <mat-chip-listbox>
7
+ <mat-chip [class.active]="currentState === state"
8
+ *ngFor="let state of conversationStates">
9
+ {{ getStateLabel(state) }}
10
+ </mat-chip>
11
+ </mat-chip-listbox>
12
+ </mat-card-subtitle>
13
+ <button mat-icon-button class="close-button" (click)="closeDialog()">
14
+ <mat-icon>close</mat-icon>
15
+ </button>
16
+ </mat-card-header>
17
+
18
+ <mat-divider></mat-divider>
19
+
20
+ <mat-card-content>
21
+ <!-- Error State -->
22
+ <div class="error-banner" *ngIf="error">
23
+ <mat-icon>error_outline</mat-icon>
24
+ <span>{{ error }}</span>
25
+ <button mat-icon-button (click)="retryConnection()">
26
+ <mat-icon>refresh</mat-icon>
27
+ </button>
28
+ </div>
29
+
30
+ <!-- Transcription Display -->
31
+ <div class="transcription-area" *ngIf="currentTranscription && currentState === 'listening'">
32
+ <div class="transcription-label">Dinleniyor...</div>
33
+ <div class="transcription-text">{{ currentTranscription }}</div>
34
+ </div>
35
+
36
+ <!-- Chat Messages -->
37
+ <div class="chat-messages" #scrollContainer>
38
+ <div *ngFor="let msg of messages; trackBy: trackByIndex"
39
+ [class]="'message ' + msg.role">
40
+ <mat-icon class="message-icon">
41
+ {{ msg.role === 'user' ? 'person' : msg.role === 'assistant' ? 'smart_toy' : 'info' }}
42
+ </mat-icon>
43
+ <div class="message-content">
44
+ <div class="message-text">{{ msg.text }}</div>
45
+ <div class="message-time">{{ msg.timestamp | date:'HH:mm:ss' }}</div>
46
+ <button *ngIf="msg.audioUrl && msg.role === 'assistant'"
47
+ mat-icon-button
48
+ (click)="playAudio(msg.audioUrl)"
49
+ class="audio-button"
50
+ [disabled]="isPlayingAudio">
51
+ <mat-icon>{{ isPlayingAudio ? 'stop' : 'volume_up' }}</mat-icon>
52
+ </button>
53
+ </div>
54
+ </div>
55
+
56
+ <!-- Empty State -->
57
+ <div class="empty-state" *ngIf="messages.length === 0 && !isConversationActive">
58
+ <mat-icon>mic_off</mat-icon>
59
+ <p>Konuşmaya başlamak için aşağıdaki butona tıklayın</p>
60
+ </div>
61
+ </div>
62
+
63
+ <!-- Audio Visualizer -->
64
+ <canvas #audioVisualizer
65
+ class="audio-visualizer"
66
+ width="600"
67
+ height="100"
68
+ [class.active]="isRecording && isConversationActive">
69
+ </canvas>
70
+ </mat-card-content>
71
+
72
+ <mat-card-actions>
73
+ <button mat-raised-button
74
+ color="primary"
75
+ (click)="toggleConversation()"
76
+ [disabled]="!sessionId || loading">
77
+ @if (loading) {
78
+ <mat-spinner diameter="20"></mat-spinner>
79
+ } @else {
80
+ <mat-icon>{{ isConversationActive ? 'stop' : 'mic' }}</mat-icon>
81
+ {{ isConversationActive ? 'Konuşmayı Bitir' : 'Konuşmaya Başla' }}
82
+ }
83
+ </button>
84
+
85
+ <button mat-button
86
+ (click)="clearChat()"
87
+ [disabled]="messages.length === 0">
88
+ <mat-icon>clear</mat-icon>
89
+ Temizle
90
+ </button>
91
+
92
+ <button mat-button
93
+ (click)="performBargeIn()"
94
+ [disabled]="!isConversationActive || currentState === 'idle' || currentState === 'listening'">
95
+ <mat-icon>pan_tool</mat-icon>
96
+ Kesme (Barge-in)
97
+ </button>
98
+ </mat-card-actions>
99
+ </mat-card>