reneco-advanced-input-module 0.0.22 → 0.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/voice-input-module.cjs.entry.js +208 -93
- package/dist/cjs/voice-input-module.cjs.entry.js.map +1 -1
- package/dist/cjs/voice-input-module.cjs.js +1 -1
- package/dist/cjs/voice-input-module.entry.cjs.js.map +1 -1
- package/dist/collection/components/voice-input-module/voice-input-module.js +209 -93
- package/dist/collection/components/voice-input-module/voice-input-module.js.map +1 -1
- package/dist/components/voice-input-module.js +209 -93
- package/dist/components/voice-input-module.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/voice-input-module.entry.js +208 -93
- package/dist/esm/voice-input-module.entry.js.map +1 -1
- package/dist/esm/voice-input-module.js +1 -1
- package/dist/types/components/voice-input-module/voice-input-module.d.ts +3 -0
- package/dist/voice-input-module/{p-0e2b9ca0.entry.js → p-920964b2.entry.js} +3 -3
- package/dist/voice-input-module/p-920964b2.entry.js.map +1 -0
- package/dist/voice-input-module/voice-input-module.entry.esm.js.map +1 -1
- package/dist/voice-input-module/voice-input-module.esm.js +1 -1
- package/package.json +1 -1
- package/www/build/{p-0e2b9ca0.entry.js → p-920964b2.entry.js} +3 -3
- package/www/build/p-920964b2.entry.js.map +1 -0
- package/www/build/{p-812b92c7.js → p-cbf8974a.js} +1 -1
- package/www/build/voice-input-module.entry.esm.js.map +1 -1
- package/www/build/voice-input-module.esm.js +1 -1
- package/www/index.html +1 -1
- package/dist/voice-input-module/p-0e2b9ca0.entry.js.map +0 -1
- package/www/build/p-0e2b9ca0.entry.js.map +0 -1
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -6,7 +6,7 @@ var appGlobals = require('./app-globals-V2Kpy_OQ.js');
|
|
|
6
6
|
const defineCustomElements = async (win, options) => {
|
|
7
7
|
if (typeof window === 'undefined') return undefined;
|
|
8
8
|
await appGlobals.globalScripts();
|
|
9
|
-
return index.bootstrapLazy([["ocr-file-uploader.cjs",[[257,"ocr-file-uploader",{"batch":[4],"callback":[16],"jsonSchema":[1,"json-schema"],"theme":[1],"parsedTheme":[32]},null,{"theme":["parseTheme"]}]]],["voice-input-module.cjs",[[257,"voice-input-module",{"formJson":[1,"form-json"],"serviceConfig":[1,"service-config"],"apiKey":[1,"api-key"],"apiProxyUrl":[1,"api-proxy-url"],"transcriptionModel":[1,"transcription-model"],"completionModel":[1,"completion-model"],"transcriptionProvider":[1,"transcription-provider"],"completionProvider":[1,"completion-provider"],"context":[1],"classificationRootUrl":[1,"classification-root-url"],"language":[1],"inputTypes":[1,"input-types"],"theme":[1],"debug":[4],"renderForm":[4,"render-form"],"displayStatus":[4,"display-status"],"isRecording":[32],"isProcessing":[32],"statusMessage":[32],"hasError":[32],"transcription":[32],"filledData":[32],"debugInfo":[32],"isReadonlyMode":[32],"convertXmlToJson":[64],"convertJsonToXml":[64],"convertXmlToJsonLegacy":[64],"convertJsonToXmlLegacy":[64]},null,{"formJson":["initializeServices"],"serviceConfig":["initializeServices"],"theme":["initializeServices"],"transcriptionProvider":["initializeServices"],"completionProvider":["initializeServices"],"transcriptionModel":["initializeServices"],"completionModel":["initializeServices"]}]]]], options);
|
|
9
|
+
return index.bootstrapLazy([["ocr-file-uploader.cjs",[[257,"ocr-file-uploader",{"batch":[4],"callback":[16],"jsonSchema":[1,"json-schema"],"theme":[1],"parsedTheme":[32]},null,{"theme":["parseTheme"]}]]],["voice-input-module.cjs",[[257,"voice-input-module",{"formJson":[1,"form-json"],"serviceConfig":[1,"service-config"],"apiKey":[1,"api-key"],"apiProxyUrl":[1,"api-proxy-url"],"transcriptionModel":[1,"transcription-model"],"completionModel":[1,"completion-model"],"transcriptionProvider":[1,"transcription-provider"],"completionProvider":[1,"completion-provider"],"context":[1],"classificationRootUrl":[1,"classification-root-url"],"language":[1],"inputTypes":[1,"input-types"],"theme":[1],"debug":[4],"renderForm":[4,"render-form"],"displayStatus":[4,"display-status"],"isRecording":[32],"isProcessing":[32],"statusMessage":[32],"hasError":[32],"hasTransientError":[32],"transcription":[32],"filledData":[32],"debugInfo":[32],"isReadonlyMode":[32],"convertXmlToJson":[64],"convertJsonToXml":[64],"convertXmlToJsonLegacy":[64],"convertJsonToXmlLegacy":[64]},null,{"formJson":["initializeServices"],"serviceConfig":["initializeServices"],"theme":["initializeServices"],"transcriptionProvider":["initializeServices"],"completionProvider":["initializeServices"],"transcriptionModel":["initializeServices"],"completionModel":["initializeServices"]}]]]], options);
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
exports.setNonce = index.setNonce;
|
|
@@ -4364,6 +4364,7 @@ const VoiceFormRecorder = class {
|
|
|
4364
4364
|
this.isRecording = false;
|
|
4365
4365
|
this.isProcessing = false;
|
|
4366
4366
|
this.hasError = false;
|
|
4367
|
+
this.hasTransientError = false;
|
|
4367
4368
|
this.transcription = '';
|
|
4368
4369
|
this.filledData = null;
|
|
4369
4370
|
this.debugInfo = {};
|
|
@@ -4376,7 +4377,21 @@ const VoiceFormRecorder = class {
|
|
|
4376
4377
|
if (!input.files || input.files.length === 0)
|
|
4377
4378
|
return;
|
|
4378
4379
|
const file = input.files[0];
|
|
4379
|
-
this.
|
|
4380
|
+
const isEn = this.language === 'en';
|
|
4381
|
+
// Validate file type
|
|
4382
|
+
const validAudioTypes = /^audio\//;
|
|
4383
|
+
const validAudioExtensions = /\.(mp3|wav|webm|m4a|ogg|flac|aac|opus)$/i;
|
|
4384
|
+
if (!validAudioTypes.test(file.type) && !validAudioExtensions.test(file.name)) {
|
|
4385
|
+
this.hasTransientError = true;
|
|
4386
|
+
this.statusMessage = isEn
|
|
4387
|
+
? `Invalid file type: "${file.name}". Please select an audio file.`
|
|
4388
|
+
: `Type de fichier invalide : "${file.name}". Veuillez sélectionner un fichier audio.`;
|
|
4389
|
+
input.value = '';
|
|
4390
|
+
return;
|
|
4391
|
+
}
|
|
4392
|
+
// Reset the input so the same file can be re-selected after an error
|
|
4393
|
+
input.value = '';
|
|
4394
|
+
await this.processAudioContent(file);
|
|
4380
4395
|
};
|
|
4381
4396
|
this.audioRecorder = new AudioRecorderService();
|
|
4382
4397
|
}
|
|
@@ -4436,6 +4451,7 @@ const VoiceFormRecorder = class {
|
|
|
4436
4451
|
config: this.parsedConfig
|
|
4437
4452
|
});
|
|
4438
4453
|
this.hasError = false;
|
|
4454
|
+
this.hasTransientError = false;
|
|
4439
4455
|
this.statusMessage = ((_a = this.parsedTheme.texts) === null || _a === void 0 ? void 0 : _a.idle) || (this.language == 'en' ? 'Select an input method' : 'Sélectionner une méthode de saisie');
|
|
4440
4456
|
if (this.parsedInputTypes.length === 0) {
|
|
4441
4457
|
this.inputTypes = 'voice';
|
|
@@ -4456,6 +4472,91 @@ const VoiceFormRecorder = class {
|
|
|
4456
4472
|
} });
|
|
4457
4473
|
}
|
|
4458
4474
|
}
|
|
4475
|
+
getMicErrorMessage(error) {
|
|
4476
|
+
var _a, _b;
|
|
4477
|
+
const isEn = this.language === 'en';
|
|
4478
|
+
const errorName = error.name || '';
|
|
4479
|
+
if (errorName === 'NotAllowedError' || errorName === 'PermissionDeniedError') {
|
|
4480
|
+
return isEn
|
|
4481
|
+
? 'Microphone access denied. Allow microphone access in your browser settings and try again.'
|
|
4482
|
+
: "Accès au microphone refusé. Autorisez l'accès au microphone dans les paramètres du navigateur et réessayez.";
|
|
4483
|
+
}
|
|
4484
|
+
if (errorName === 'NotFoundError' || errorName === 'DevicesNotFoundError') {
|
|
4485
|
+
return isEn
|
|
4486
|
+
? 'No microphone found. Please connect a microphone and try again.'
|
|
4487
|
+
: 'Aucun microphone trouvé. Connectez un microphone et réessayez.';
|
|
4488
|
+
}
|
|
4489
|
+
if (errorName === 'NotReadableError' || errorName === 'TrackStartError') {
|
|
4490
|
+
return isEn
|
|
4491
|
+
? 'Microphone is busy or unavailable. Close other apps using the microphone and try again.'
|
|
4492
|
+
: 'Le microphone est occupé ou indisponible. Fermez les autres applications utilisant le microphone et réessayez.';
|
|
4493
|
+
}
|
|
4494
|
+
if (errorName === 'AbortError') {
|
|
4495
|
+
return isEn
|
|
4496
|
+
? 'Microphone access was interrupted. Please try again.'
|
|
4497
|
+
: "L'accès au microphone a été interrompu. Veuillez réessayer.";
|
|
4498
|
+
}
|
|
4499
|
+
if (errorName === 'OverconstrainedError') {
|
|
4500
|
+
return isEn
|
|
4501
|
+
? 'Microphone does not support the required audio settings.'
|
|
4502
|
+
: 'Le microphone ne supporte pas les paramètres audio requis.';
|
|
4503
|
+
}
|
|
4504
|
+
if (((_a = error.message) === null || _a === void 0 ? void 0 : _a.includes('HTTPS')) || ((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('not supported'))) {
|
|
4505
|
+
return isEn
|
|
4506
|
+
? 'Microphone access requires HTTPS or localhost.'
|
|
4507
|
+
: "L'accès au microphone nécessite HTTPS ou localhost.";
|
|
4508
|
+
}
|
|
4509
|
+
return isEn ? `Microphone error: ${error.message}` : `Erreur microphone : ${error.message}`;
|
|
4510
|
+
}
|
|
4511
|
+
getReadableErrorMessage(error, phase) {
|
|
4512
|
+
const isEn = this.language === 'en';
|
|
4513
|
+
const msg = error.message || '';
|
|
4514
|
+
if (/401|unauthorized|invalid.{0,20}(api )?key|authentication failed/i.test(msg)) {
|
|
4515
|
+
return isEn
|
|
4516
|
+
? 'Authentication failed: invalid API key. Check your configuration.'
|
|
4517
|
+
: "Échec d'authentification : clé API invalide. Vérifiez votre configuration.";
|
|
4518
|
+
}
|
|
4519
|
+
if (/403|forbidden/i.test(msg)) {
|
|
4520
|
+
return isEn
|
|
4521
|
+
? 'Access denied: check your API permissions.'
|
|
4522
|
+
: 'Accès refusé : vérifiez vos permissions API.';
|
|
4523
|
+
}
|
|
4524
|
+
if (/429|rate.{0,10}limit|too many requests/i.test(msg)) {
|
|
4525
|
+
return isEn
|
|
4526
|
+
? 'Rate limit exceeded. Please wait a moment and try again.'
|
|
4527
|
+
: 'Limite de requêtes dépassée. Veuillez attendre quelques secondes et réessayer.';
|
|
4528
|
+
}
|
|
4529
|
+
if (/404|not found/i.test(msg)) {
|
|
4530
|
+
return isEn
|
|
4531
|
+
? 'API endpoint not found. Check your proxy URL configuration.'
|
|
4532
|
+
: "Endpoint API introuvable. Vérifiez l'URL de votre proxy.";
|
|
4533
|
+
}
|
|
4534
|
+
if (/5\d\d|server error|internal server|bad gateway|service unavailable/i.test(msg)) {
|
|
4535
|
+
return isEn
|
|
4536
|
+
? 'Server error. Please try again in a moment.'
|
|
4537
|
+
: 'Erreur serveur. Veuillez réessayer dans un instant.';
|
|
4538
|
+
}
|
|
4539
|
+
if (/network|failed to fetch|err_connection|connection refused/i.test(msg)) {
|
|
4540
|
+
return isEn
|
|
4541
|
+
? 'Network error: check your connection and proxy server.'
|
|
4542
|
+
: 'Erreur réseau : vérifiez votre connexion et le serveur proxy.';
|
|
4543
|
+
}
|
|
4544
|
+
if (/json|parse error|unexpected token|invalid response/i.test(msg)) {
|
|
4545
|
+
return isEn
|
|
4546
|
+
? 'Unexpected response from AI service. Please try again.'
|
|
4547
|
+
: 'Réponse inattendue du service IA. Veuillez réessayer.';
|
|
4548
|
+
}
|
|
4549
|
+
if (phase === 'transcription') {
|
|
4550
|
+
return isEn ? `Transcription failed: ${msg}` : `Échec de la transcription : ${msg}`;
|
|
4551
|
+
}
|
|
4552
|
+
if (phase === 'llm') {
|
|
4553
|
+
return isEn ? `Form filling failed: ${msg}` : `Échec du remplissage du formulaire : ${msg}`;
|
|
4554
|
+
}
|
|
4555
|
+
if (phase === 'ocr') {
|
|
4556
|
+
return isEn ? `OCR processing failed: ${msg}` : `Échec du traitement OCR : ${msg}`;
|
|
4557
|
+
}
|
|
4558
|
+
return isEn ? `Processing error: ${msg}` : `Erreur de traitement : ${msg}`;
|
|
4559
|
+
}
|
|
4459
4560
|
async handleRecordClick() {
|
|
4460
4561
|
if (this.isProcessing)
|
|
4461
4562
|
return;
|
|
@@ -4469,7 +4570,7 @@ const VoiceFormRecorder = class {
|
|
|
4469
4570
|
async startRecording() {
|
|
4470
4571
|
var _a;
|
|
4471
4572
|
try {
|
|
4472
|
-
this.
|
|
4573
|
+
this.hasTransientError = false;
|
|
4473
4574
|
this.statusMessage = (this.language == 'en' ? 'Starting recording...' : `Enregistrement ...`);
|
|
4474
4575
|
this.updateDebugInfo('Start Recording Attempt', {});
|
|
4475
4576
|
await this.audioRecorder.startRecording();
|
|
@@ -4482,8 +4583,8 @@ const VoiceFormRecorder = class {
|
|
|
4482
4583
|
});
|
|
4483
4584
|
}
|
|
4484
4585
|
catch (error) {
|
|
4485
|
-
this.
|
|
4486
|
-
this.statusMessage =
|
|
4586
|
+
this.hasTransientError = true;
|
|
4587
|
+
this.statusMessage = this.getMicErrorMessage(error);
|
|
4487
4588
|
this.updateDebugInfo('Recording Error', { error: error.message });
|
|
4488
4589
|
this.formFilled.emit({
|
|
4489
4590
|
success: false,
|
|
@@ -4493,40 +4594,36 @@ const VoiceFormRecorder = class {
|
|
|
4493
4594
|
}
|
|
4494
4595
|
async processJsonForm(ocrData) {
|
|
4495
4596
|
var _a, _b, _c;
|
|
4597
|
+
this.isProcessing = true;
|
|
4598
|
+
this.hasTransientError = false;
|
|
4599
|
+
this.statusMessage = ((_a = this.parsedTheme.texts) === null || _a === void 0 ? void 0 : _a.processing) || (this.language == 'en' ? 'Processing document...' : 'Traitement du document ...');
|
|
4496
4600
|
try {
|
|
4497
|
-
this.isProcessing = true;
|
|
4498
|
-
this.statusMessage = ((_a = this.parsedTheme.texts) === null || _a === void 0 ? void 0 : _a.processing) || (this.language == 'en' ? 'Processing json...' : `Traitement du json ...`);
|
|
4499
|
-
// Extract content from OCR format
|
|
4500
4601
|
const extractedData = (ocrData === null || ocrData === void 0 ? void 0 : ocrData.content) || ocrData;
|
|
4501
4602
|
const jsonForm = JSON.stringify(extractedData);
|
|
4502
|
-
|
|
4603
|
+
if (!extractedData) {
|
|
4604
|
+
throw Object.assign(new Error('OCR returned no data'), { phase: 'ocr' });
|
|
4605
|
+
}
|
|
4503
4606
|
this.statusMessage = ((_b = this.parsedTheme.texts) === null || _b === void 0 ? void 0 : _b.filling) || (this.language == 'en' ? 'Filling form fields...' : 'Remplissage du formulaire ...');
|
|
4504
4607
|
const trimmedSchema = await this.trimSchemaForAI(this.parsedSchema);
|
|
4505
|
-
|
|
4506
|
-
|
|
4608
|
+
let filledSchema;
|
|
4609
|
+
try {
|
|
4610
|
+
filledSchema = await this.llmService.fillFormFromJson(jsonForm, trimmedSchema);
|
|
4611
|
+
}
|
|
4612
|
+
catch (llmError) {
|
|
4613
|
+
throw Object.assign(new Error(llmError.message), { phase: 'llm' });
|
|
4614
|
+
}
|
|
4507
4615
|
this.filledData = this.extractFilledData(filledSchema);
|
|
4508
|
-
this.updateDebugInfo('Form Filled', {
|
|
4509
|
-
filledSchema,
|
|
4510
|
-
extractedData: this.filledData
|
|
4511
|
-
});
|
|
4616
|
+
this.updateDebugInfo('Form Filled', { filledSchema, extractedData: this.filledData });
|
|
4512
4617
|
this.parsedSchema = this.filledData;
|
|
4513
|
-
this.statusMessage = ((_c = this.parsedTheme.texts) === null || _c === void 0 ? void 0 : _c.completed) || (this.language == 'en' ? 'Form completed!' : 'Formulaire
|
|
4514
|
-
this.
|
|
4515
|
-
// Emit success event
|
|
4516
|
-
this.formFilled.emit({
|
|
4517
|
-
success: true,
|
|
4518
|
-
data: this.filledData,
|
|
4519
|
-
jsonForm: jsonForm
|
|
4520
|
-
});
|
|
4618
|
+
this.statusMessage = ((_c = this.parsedTheme.texts) === null || _c === void 0 ? void 0 : _c.completed) || (this.language == 'en' ? 'Form completed!' : 'Formulaire rempli !');
|
|
4619
|
+
this.formFilled.emit({ success: true, data: this.filledData, jsonForm });
|
|
4521
4620
|
}
|
|
4522
4621
|
catch (error) {
|
|
4523
|
-
|
|
4524
|
-
this.
|
|
4525
|
-
this.
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
jsonForm: JSON.stringify(ocrData)
|
|
4529
|
-
});
|
|
4622
|
+
console.error('OCR processing error:', error);
|
|
4623
|
+
this.hasTransientError = true;
|
|
4624
|
+
this.statusMessage = this.getReadableErrorMessage(error, error.phase || 'llm');
|
|
4625
|
+
this.updateDebugInfo('OCR Processing Error', { phase: error.phase, error: error.message });
|
|
4626
|
+
this.formFilled.emit({ success: false, error: error.message, jsonForm: JSON.stringify(ocrData) });
|
|
4530
4627
|
}
|
|
4531
4628
|
finally {
|
|
4532
4629
|
this.isProcessing = false;
|
|
@@ -4534,83 +4631,100 @@ const VoiceFormRecorder = class {
|
|
|
4534
4631
|
}
|
|
4535
4632
|
async processAudioContent(audioFile) {
|
|
4536
4633
|
var _a, _b, _c;
|
|
4537
|
-
this.
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
});
|
|
4634
|
+
this.isProcessing = true;
|
|
4635
|
+
this.hasTransientError = false;
|
|
4636
|
+
this.updateDebugInfo('Audio Captured', { size: audioFile.size, type: audioFile.type });
|
|
4541
4637
|
try {
|
|
4542
|
-
//
|
|
4543
|
-
|
|
4544
|
-
|
|
4545
|
-
|
|
4546
|
-
|
|
4638
|
+
// Validate audio file before sending to API
|
|
4639
|
+
const MAX_AUDIO_SIZE = 25 * 1024 * 1024; // 25MB (API limit)
|
|
4640
|
+
if (audioFile.size <= 44) { // WAV header alone is 44 bytes; effectively empty
|
|
4641
|
+
this.hasTransientError = true;
|
|
4642
|
+
this.statusMessage = this.language == 'en'
|
|
4643
|
+
? 'Recording is empty or too short. Please try again.'
|
|
4644
|
+
: "L'enregistrement est vide ou trop court. Veuillez réessayer.";
|
|
4645
|
+
this.formFilled.emit({ success: false, error: 'Empty or too short audio' });
|
|
4646
|
+
return;
|
|
4647
|
+
}
|
|
4648
|
+
if (audioFile.size > MAX_AUDIO_SIZE) {
|
|
4649
|
+
this.hasTransientError = true;
|
|
4650
|
+
this.statusMessage = this.language == 'en'
|
|
4651
|
+
? `File too large (${Math.round(audioFile.size / 1024 / 1024)}MB). Maximum is 25MB.`
|
|
4652
|
+
: `Fichier trop volumineux (${Math.round(audioFile.size / 1024 / 1024)}Mo). Maximum : 25Mo.`;
|
|
4653
|
+
this.formFilled.emit({ success: false, error: 'Audio file too large' });
|
|
4654
|
+
return;
|
|
4655
|
+
}
|
|
4656
|
+
// Step 1: Transcription
|
|
4657
|
+
let transcription;
|
|
4658
|
+
try {
|
|
4659
|
+
this.statusMessage = ((_a = this.parsedTheme.texts) === null || _a === void 0 ? void 0 : _a.transcribing) || (this.language == 'en' ? 'Transcribing speech...' : 'Transcription du texte ...');
|
|
4660
|
+
transcription = await this.speechToTextService.transcribe(audioFile, this.language);
|
|
4661
|
+
this.transcription = transcription;
|
|
4662
|
+
this.updateDebugInfo('Transcription Complete', { transcription });
|
|
4663
|
+
}
|
|
4664
|
+
catch (transcriptionError) {
|
|
4665
|
+
throw Object.assign(new Error(transcriptionError.message), { phase: 'transcription' });
|
|
4666
|
+
}
|
|
4547
4667
|
if (!transcription.trim()) {
|
|
4548
|
-
|
|
4668
|
+
this.hasTransientError = true;
|
|
4669
|
+
this.statusMessage = this.language == 'en'
|
|
4670
|
+
? 'No speech detected. Please speak clearly and try again.'
|
|
4671
|
+
: 'Aucune parole détectée. Parlez clairement et réessayez.';
|
|
4672
|
+
this.formFilled.emit({ success: false, error: 'No speech detected', transcription: '' });
|
|
4673
|
+
return;
|
|
4674
|
+
}
|
|
4675
|
+
// Step 2: LLM form filling
|
|
4676
|
+
let filledSchema;
|
|
4677
|
+
try {
|
|
4678
|
+
this.statusMessage = ((_b = this.parsedTheme.texts) === null || _b === void 0 ? void 0 : _b.filling) || (this.language == 'en' ? 'Filling form fields...' : 'Remplissage du formulaire ...');
|
|
4679
|
+
const trimmedSchema = await this.trimSchemaForAI(this.parsedSchema);
|
|
4680
|
+
filledSchema = await this.llmService.fillFormFromTranscription(transcription, trimmedSchema);
|
|
4681
|
+
}
|
|
4682
|
+
catch (llmError) {
|
|
4683
|
+
throw Object.assign(new Error(llmError.message), { phase: 'llm' });
|
|
4549
4684
|
}
|
|
4550
|
-
// Fill form using LLM
|
|
4551
|
-
this.statusMessage = ((_b = this.parsedTheme.texts) === null || _b === void 0 ? void 0 : _b.filling) || (this.language == 'en' ? 'Filling form fields...' : 'Remplissage du formulaire ...');
|
|
4552
|
-
const trimmedSchema = await this.trimSchemaForAI(this.parsedSchema);
|
|
4553
|
-
const filledSchema = await this.llmService.fillFormFromTranscription(transcription, trimmedSchema);
|
|
4554
|
-
// Extract filled data
|
|
4555
4685
|
this.filledData = this.extractFilledData(filledSchema);
|
|
4556
|
-
this.updateDebugInfo('Form Filled', {
|
|
4557
|
-
filledSchema,
|
|
4558
|
-
extractedData: this.filledData
|
|
4559
|
-
});
|
|
4686
|
+
this.updateDebugInfo('Form Filled', { filledSchema, extractedData: this.filledData });
|
|
4560
4687
|
this.parsedSchema = this.filledData;
|
|
4561
|
-
this.statusMessage = ((_c = this.parsedTheme.texts) === null || _c === void 0 ? void 0 : _c.completed) || (this.language == 'en' ? 'Form completed!' : 'Formulaire
|
|
4562
|
-
this.
|
|
4563
|
-
// Emit success event
|
|
4564
|
-
this.formFilled.emit({
|
|
4565
|
-
success: true,
|
|
4566
|
-
data: this.filledData,
|
|
4567
|
-
transcription: transcription
|
|
4568
|
-
});
|
|
4688
|
+
this.statusMessage = ((_c = this.parsedTheme.texts) === null || _c === void 0 ? void 0 : _c.completed) || (this.language == 'en' ? 'Form completed!' : 'Formulaire rempli !');
|
|
4689
|
+
this.formFilled.emit({ success: true, data: this.filledData, transcription });
|
|
4569
4690
|
}
|
|
4570
4691
|
catch (error) {
|
|
4571
|
-
console.error('
|
|
4572
|
-
this.
|
|
4573
|
-
this.statusMessage =
|
|
4574
|
-
this.updateDebugInfo('
|
|
4575
|
-
this.formFilled.emit({
|
|
4576
|
-
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
});
|
|
4692
|
+
console.error('Audio processing error:', error);
|
|
4693
|
+
this.hasTransientError = true;
|
|
4694
|
+
this.statusMessage = this.getReadableErrorMessage(error, error.phase || 'audio-upload');
|
|
4695
|
+
this.updateDebugInfo('Audio Processing Error', { phase: error.phase, error: error.message });
|
|
4696
|
+
this.formFilled.emit({ success: false, error: error.message, transcription: this.transcription });
|
|
4697
|
+
}
|
|
4698
|
+
finally {
|
|
4699
|
+
this.isProcessing = false;
|
|
4580
4700
|
}
|
|
4581
4701
|
}
|
|
4582
4702
|
async stopRecordingAndProcess() {
|
|
4583
4703
|
var _a;
|
|
4704
|
+
this.isRecording = false;
|
|
4705
|
+
this.isProcessing = true;
|
|
4706
|
+
this.hasTransientError = false;
|
|
4707
|
+
this.statusMessage = ((_a = this.parsedTheme.texts) === null || _a === void 0 ? void 0 : _a.processing) || (this.language == 'en' ? 'Processing audio...' : `Traitement de l'audio ...`);
|
|
4708
|
+
this.updateDebugInfo('Stop Recording', {});
|
|
4709
|
+
this.recordingStateChanged.emit({ isRecording: false, state: 'processing' });
|
|
4584
4710
|
try {
|
|
4585
|
-
this.isRecording = false;
|
|
4586
|
-
this.isProcessing = true;
|
|
4587
|
-
this.statusMessage = ((_a = this.parsedTheme.texts) === null || _a === void 0 ? void 0 : _a.processing) || (this.language == 'en' ? 'Processing audio...' : `Traitement de l'audio ...`);
|
|
4588
|
-
this.updateDebugInfo('Stop Recording', {});
|
|
4589
|
-
this.recordingStateChanged.emit({
|
|
4590
|
-
isRecording: false,
|
|
4591
|
-
state: 'processing'
|
|
4592
|
-
});
|
|
4593
|
-
// Stop recording and get audio blob
|
|
4594
4711
|
const audioBlob = await this.audioRecorder.stopRecording();
|
|
4595
4712
|
const audioContent = new File([audioBlob], 'audio.wav', { type: 'audio/wav' });
|
|
4596
|
-
|
|
4713
|
+
// processAudioContent manages isProcessing itself; await ensures we don't return early
|
|
4714
|
+
await this.processAudioContent(audioContent);
|
|
4597
4715
|
}
|
|
4598
4716
|
catch (error) {
|
|
4599
|
-
|
|
4600
|
-
this.
|
|
4601
|
-
this.
|
|
4602
|
-
this.
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
});
|
|
4717
|
+
// Only reached if audioRecorder.stopRecording() itself throws
|
|
4718
|
+
this.hasTransientError = true;
|
|
4719
|
+
this.isProcessing = false;
|
|
4720
|
+
this.statusMessage = (this.language == 'en'
|
|
4721
|
+
? `Failed to stop recording: ${error.message}`
|
|
4722
|
+
: `Impossible d'arrêter l'enregistrement : ${error.message}`);
|
|
4723
|
+
this.updateDebugInfo('Stop Recording Error', { error: error.message });
|
|
4724
|
+
this.formFilled.emit({ success: false, error: error.message, transcription: this.transcription });
|
|
4607
4725
|
}
|
|
4608
4726
|
finally {
|
|
4609
|
-
this.
|
|
4610
|
-
this.recordingStateChanged.emit({
|
|
4611
|
-
isRecording: false,
|
|
4612
|
-
state: 'idle'
|
|
4613
|
-
});
|
|
4727
|
+
this.recordingStateChanged.emit({ isRecording: false, state: 'idle' });
|
|
4614
4728
|
}
|
|
4615
4729
|
}
|
|
4616
4730
|
extractFilledData(filledData) {
|
|
@@ -4918,12 +5032,14 @@ const VoiceFormRecorder = class {
|
|
|
4918
5032
|
return (index.h("button", { class: buttonClass, style: buttonStyle, onClick: () => this.handleRecordClick(), disabled: isDisabled, "aria-label": this.isRecording ? 'Stop recording' : 'Start recording' }, this.isProcessing ? (index.h("svg", { class: "record-icon", viewBox: "0 0 24 24" }, index.h("circle", { cx: "12", cy: "12", r: "3" }, index.h("animate", { attributeName: "r", values: "3;6;3", dur: "1s", repeatCount: "indefinite" }), index.h("animate", { attributeName: "opacity", values: "1;0.3;1", dur: "1s", repeatCount: "indefinite" })))) : this.isRecording ? (index.h("svg", { class: "record-icon", viewBox: "0 0 24 24" }, index.h("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }))) : (index.h("svg", { class: "record-icon", viewBox: "0 0 24 24" }, index.h("circle", { cx: "12", cy: "12", r: "8" })))));
|
|
4919
5033
|
}
|
|
4920
5034
|
renderStatusMessage() {
|
|
5035
|
+
const hasAnyError = this.hasError || this.hasTransientError;
|
|
4921
5036
|
const statusClass = [
|
|
4922
5037
|
'status-text',
|
|
4923
|
-
|
|
4924
|
-
this.filledData && !
|
|
5038
|
+
hasAnyError && 'error',
|
|
5039
|
+
this.filledData && !hasAnyError && 'success'
|
|
4925
5040
|
].filter(Boolean).join(' ');
|
|
4926
|
-
|
|
5041
|
+
const statusStyle = this.getStatusStyle();
|
|
5042
|
+
return index.h("div", { class: statusClass, style: statusStyle }, this.statusMessage);
|
|
4927
5043
|
}
|
|
4928
5044
|
renderFormPreview() {
|
|
4929
5045
|
if (!this.parsedSchema)
|
|
@@ -5096,8 +5212,7 @@ const VoiceFormRecorder = class {
|
|
|
5096
5212
|
}
|
|
5097
5213
|
render() {
|
|
5098
5214
|
const containerStyle = this.getContainerStyle();
|
|
5099
|
-
|
|
5100
|
-
return (index.h("div", { key: '8378e98f02e5b7482929d255c5ec12ff8c2731e4' }, index.h("div", { key: 'b8a0d873bd4e1b4c8936747c0919ac8c4c15301b', class: "voice-recorder-container" + (this.debug || this.renderForm ? "-debug" : ""), style: containerStyle }, index.h("div", { key: '86e7783e3686db378ee16aa91a640f33c3255923', class: "row-audio-area" }, this.renderRecordButton(), this.renderUploadRecordButton(), this.renderUploadButton()), this.displayStatus ? index.h("div", { class: "status-text", style: statusStyle }, this.statusMessage) : "", this.renderForm ? this.renderFormPreview() : "", this.debug ? this.renderDebugPanel() : "")));
|
|
5215
|
+
return (index.h("div", { key: 'd2eb6b74840a57809920b3dbba3fd7dfbeef8531' }, index.h("div", { key: 'e66e1d4fc23176f9024ca20413535440a8be3ce8', class: "voice-recorder-container" + (this.debug || this.renderForm ? "-debug" : ""), style: containerStyle }, index.h("div", { key: '57dd7b882771d1f0bd56a97bfd0a06ffee09428e', class: "row-audio-area" }, this.renderRecordButton(), this.renderUploadRecordButton(), this.renderUploadButton()), this.displayStatus ? this.renderStatusMessage() : "", this.renderForm ? this.renderFormPreview() : "", this.debug ? this.renderDebugPanel() : "")));
|
|
5101
5216
|
}
|
|
5102
5217
|
static get watchers() { return {
|
|
5103
5218
|
"formJson": ["initializeServices"],
|