feat(voice): enhance streaming engine and improve system reliability
Improve the PCM playback worklet with robust resampling and buffer management. Refactor the voice-stream service for better session teardown and error handling. Fix authentication issues by enabling credentials in HttpService and using relative URLs. Add Jalali date support and an AI model configuration tab in settings. Enhance diagnostics for voice transport and the audio engine.
This commit is contained in:
@@ -54,9 +54,9 @@
|
||||
appearance: none;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
||||
background-repeat: no-repeat;
|
||||
background-position: right 0.75rem center;
|
||||
padding-right: 2.5rem;
|
||||
padding-left: 0.75rem;
|
||||
background-position: right 1rem center;
|
||||
padding: 0.75rem 1rem;
|
||||
padding-right: 2.75rem;
|
||||
background-color: var(--color-input-bg);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--color-input-border);
|
||||
@@ -95,7 +95,7 @@
|
||||
|
||||
.form-visibility-toggle {
|
||||
position: absolute;
|
||||
inset-inline-start: 0.5rem;
|
||||
inset-inline-end: 0.5rem;
|
||||
top: 50%;
|
||||
translate: 0 -50%;
|
||||
display: flex;
|
||||
|
||||
@@ -41,44 +41,47 @@ interface ModelOption {
|
||||
<div class="ai-model-card settings-card">
|
||||
<header class="ai-model-card-header">
|
||||
<h3 class="text-base font-medium text-[var(--text-primary)]">{{ title() }}</h3>
|
||||
<span class="ai-model-badge" [class.ai-model-badge--connected]="connected()"
|
||||
>{{ connected() ? 'متصل' : 'متصل نشده' }}</span>
|
||||
<span class="ai-model-badge" [class.ai-model-badge--connected]="connected()">{{
|
||||
connected() ? 'متصل' : 'متصل نشده'
|
||||
}}</span>
|
||||
</header>
|
||||
|
||||
<div class="ai-model-body space-y-4">
|
||||
<!-- Provider -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">ارائهدهنده</label>
|
||||
<select
|
||||
class="form-select w-full"
|
||||
[value]="config().provider"
|
||||
(change)="onProviderChange($any($event.target).value)"
|
||||
>
|
||||
@for (provider of providers(); track provider.value) {
|
||||
<option [value]="provider.value">{{ provider.label }}</option>
|
||||
}
|
||||
</select>
|
||||
<select
|
||||
class="form-select w-full"
|
||||
[value]="config().provider"
|
||||
(change)="onProviderChange($any($event.target).value)"
|
||||
>
|
||||
@for (provider of providers(); track provider.value) {
|
||||
<option [value]="provider.value">{{ provider.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Model -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">مدل</label>
|
||||
<select
|
||||
class="form-select w-full"
|
||||
[value]="config().model"
|
||||
(change)="onModelChange($any($event.target).value)"
|
||||
>
|
||||
@for (model of modelsForProvider(); track model.value) {
|
||||
<option [value]="model.value">{{ model.label }}</option>
|
||||
}
|
||||
</select>
|
||||
<select
|
||||
class="form-select w-full"
|
||||
[value]="config().model"
|
||||
(change)="onModelChange($any($event.target).value)"
|
||||
>
|
||||
@for (model of modelsForProvider(); track model.value) {
|
||||
<option [value]="model.value">{{ model.label }}</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- API key -->
|
||||
<div class="form-field">
|
||||
<label class="form-label">
|
||||
کلید API
|
||||
@if (apiKeyRequired()) { <span class="form-required" aria-hidden="true">*</span> }
|
||||
@if (apiKeyRequired()) {
|
||||
<span class="form-required" aria-hidden="true">*</span>
|
||||
}
|
||||
</label>
|
||||
<div class="relative">
|
||||
<input
|
||||
@@ -96,25 +99,42 @@ interface ModelOption {
|
||||
[attr.aria-label]="config().apiKeyVisible ? 'پنهان کن' : 'نمایش بده'"
|
||||
(click)="toggleApiKeyVisibility()"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
aria-hidden="true"
|
||||
>
|
||||
@if (config().apiKeyVisible) {
|
||||
<path d="M1 1l22 22M10.5 10.5A2.5 2.5 0 0 0 13.5 13.5M9.9 9.9L4.15 18.5A9.92 9.92 0 0 1 1 12 11.5 11.5 0 0 1 9.9 9.9Zm10.2 10.2A11.5 11.5 0 0 0 23 12a11.5 11.5 0 0 1-3.35-7.75l2.1-2.1A11.33 11.33 0 0 1 23 12a11.5 11.5 0 0 0-3.35 7.75Z" />
|
||||
<circle cx="12" cy="12" r="1" />
|
||||
<line x1="1" y1="1" x2="23" y2="23" />
|
||||
<!-- Eye Off: API key is visible -->
|
||||
<path d="M10.58 10.58a2 2 0 0 0 2.83 2.83" />
|
||||
<path
|
||||
d="M16.68 16.68A10.7 10.7 0 0 1 12 17.75c-5 0-8.27-3.11-10-5.75a1.8 1.8 0 0 1 0-2A11.8 11.8 0 0 1 5.32 6.33"
|
||||
/>
|
||||
<path
|
||||
d="M9.88 5.08A10.7 10.7 0 0 1 12 4.75c5 0 8.27 3.11 10 5.75a1.8 1.8 0 0 1 0 2 11.8 11.8 0 0 1-1.82 2.32"
|
||||
/>
|
||||
<line x1="2" y1="2" x2="22" y2="22" />
|
||||
} @else {
|
||||
<path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7-11-7-11-7z" />
|
||||
<!-- Eye: API key is hidden -->
|
||||
<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z" />
|
||||
<circle cx="12" cy="12" r="3" />
|
||||
<line x1="12" y1="1" x2="12" y2="12.01" />
|
||||
}
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div class="form-hint">
|
||||
@if (connected() && config().apiKey) {
|
||||
<span class="text-[var(--text-muted)]">تنظیم شده — مقدار فعلی نمایش داده نمیشود</span>
|
||||
<span class="text-[var(--text-muted)]"
|
||||
>تنظیم شده — مقدار فعلی نمایش داده نمیشود</span
|
||||
>
|
||||
} @else {
|
||||
<span class="text-[var(--text-muted)]">کلید در حافظه نگهداری میشود و ذخیره نمیشود</span>
|
||||
<span class="text-[var(--text-muted)]"
|
||||
>کلید در حافظه نگهداری میشود و ذخیره نمیشود</span
|
||||
>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -131,14 +151,21 @@ interface ModelOption {
|
||||
[attr.aria-label]="'آدرس سرویس ' + title()"
|
||||
/>
|
||||
@if (!serviceUrlEditable()) {
|
||||
<span class="text-[var(--text-muted)] mt-1 text-xs">آدرس استاندارد {{ config().provider === 'local' ? 'سرویس محلی' : 'سرویس' }} بهصورت پیشفرض به کار میرود</span>
|
||||
<span class="text-[var(--text-muted)] mt-1 text-xs"
|
||||
>آدرس استاندارد {{ config().provider === 'local' ? 'سرویس محلی' : 'سرویس' }} بهصورت
|
||||
پیشفرض به کار میرود</span
|
||||
>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Actions -->
|
||||
<div class="ai-model-actions flex gap-2 pt-2">
|
||||
<button type="button" class="btn btn--primary flex-1" (click)="save.emit()">ذخیره تنظیمات</button>
|
||||
<button type="button" class="btn btn--outline flex-1" (click)="testConnection.emit()">بررسی اتصال</button>
|
||||
<button type="button" class="btn btn--primary flex-1" (click)="save.emit()">
|
||||
ذخیره تنظیمات
|
||||
</button>
|
||||
<button type="button" class="btn btn--outline flex-1" (click)="testConnection.emit()">
|
||||
بررسی اتصال
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -240,10 +267,7 @@ const DEFAULT_CONFIG_FOR: Record<AiProvider, { model: string; serviceUrl: string
|
||||
|
||||
const MODEL_OPTION = (value: string, label: string): ModelOption => ({ value, label });
|
||||
|
||||
const MODELS_BY_TASK: Record<
|
||||
AiTask,
|
||||
Partial<Record<AiProvider, ModelOption[]>>
|
||||
> = {
|
||||
const MODELS_BY_TASK: Record<AiTask, Partial<Record<AiProvider, ModelOption[]>>> = {
|
||||
text: {
|
||||
openai: [
|
||||
MODEL_OPTION('gpt-4o', 'GPT-4o'),
|
||||
|
||||
@@ -21,7 +21,7 @@ export interface ChatHistoryItem {
|
||||
imports: [CommonModule, RouterModule, CdkMenuModule],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
templateUrl: './sidebar.component.html',
|
||||
styleUrl: './sidebar.component.css'
|
||||
styleUrl: './sidebar.component.css',
|
||||
})
|
||||
export class SidebarComponent {
|
||||
private readonly themeService = inject(ThemeService);
|
||||
@@ -56,11 +56,11 @@ export class SidebarComponent {
|
||||
},
|
||||
{
|
||||
icon: 'M7.9 20A9 9 0 1 0 4 16.1L2 22Z',
|
||||
label: 'سوالات چت سایت و اپلیکیشن',
|
||||
label: 'سوالات چت وب اپلیکیشن',
|
||||
route: '/chat-questions',
|
||||
},
|
||||
{
|
||||
icon: 'M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.573-1.066zM15 12a3 3 0 11-6 0 3 3 0 016 0z',
|
||||
icon: 'M19.14 12.94c.04-.3.06-.61.06-.94s-.02-.64-.07-.94l2.03-1.58a.5.5 0 0 0 .12-.64l-1.92-3.32a.5.5 0 0 0-.61-.22l-2.39.96a7.3 7.3 0 0 0-1.63-.94l-.36-2.54A.49.49 0 0 0 13.87 2h-3.84a.49.49 0 0 0-.49.42L9.18 4.96c-.59.23-1.14.55-1.63.94l-2.39-.96a.5.5 0 0 0-.61.22L2.63 8.48a.5.5 0 0 0 .12.64l2.03 1.58a7 7 0 0 0 0 1.88l-2.03 1.58a.5.5 0 0 0-.12.64l1.92 3.32c.13.22.39.31.61.22l2.39-.96c.49.39 1.04.71 1.63.94l.36 2.54c.03.24.24.42.49.42h3.84c.25 0 .46-.18.49-.42l.36-2.54c.59-.23 1.14-.55 1.63-.94l2.39.96c.22.09.48 0 .61-.22l1.92-3.32a.5.5 0 0 0-.12-.64zM12 15.5a3.5 3.5 0 1 1 0-7 3.5 3.5 0 0 1 0 7z',
|
||||
label: 'تنظیمات',
|
||||
route: '/settings',
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user