echogarden 0.11.19 → 0.11.21
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/api/Synthesis.js +5 -4
- package/dist/api/Synthesis.js.map +1 -1
- package/dist/cli/CLI.js +2 -0
- package/dist/cli/CLI.js.map +1 -1
- package/dist/math/VectorMath.js +4 -4
- package/dist/math/VectorMath.js.map +1 -1
- package/dist/synthesis/AzureCognitiveServicesTTS.js +1 -1
- package/dist/synthesis/AzureCognitiveServicesTTS.js.map +1 -1
- package/dist/synthesis/MicrosoftEdgeTTS.js +45 -6
- package/dist/synthesis/MicrosoftEdgeTTS.js.map +1 -1
- package/dist/utilities/Logger.d.ts +2 -0
- package/dist/utilities/Logger.js +8 -1
- package/dist/utilities/Logger.js.map +1 -1
- package/dist/utilities/Utilities.d.ts +2 -0
- package/dist/utilities/Utilities.js +22 -1
- package/dist/utilities/Utilities.js.map +1 -1
- package/package.json +9 -9
- package/src/api/Synthesis.ts +15 -4
- package/src/cli/CLI.ts +2 -0
- package/src/math/VectorMath.ts +5 -4
- package/src/synthesis/AzureCognitiveServicesTTS.ts +1 -1
- package/src/synthesis/MicrosoftEdgeTTS.ts +60 -6
- package/src/utilities/Logger.ts +12 -1
- package/src/utilities/Utilities.ts +38 -4
|
@@ -4,6 +4,8 @@ import { inspect } from 'node:util'
|
|
|
4
4
|
|
|
5
5
|
import { RandomGenerator } from './RandomGenerator.js'
|
|
6
6
|
import { randomUUID, randomBytes } from 'node:crypto'
|
|
7
|
+
import { Logger } from './Logger.js'
|
|
8
|
+
import chalk from 'chalk'
|
|
7
9
|
|
|
8
10
|
const log = logToStderr
|
|
9
11
|
|
|
@@ -445,9 +447,9 @@ export function splitFilenameOnExtendedExtension(filenameWithExtension: string)
|
|
|
445
447
|
splitPoint = i
|
|
446
448
|
|
|
447
449
|
continue
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
450
|
+
} else {
|
|
451
|
+
break
|
|
452
|
+
}
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
455
|
|
|
@@ -566,9 +568,41 @@ export function getConsecutiveRepetitionScoreRelativeToFirstSubstring(tokens: st
|
|
|
566
568
|
export async function resolveModuleScriptPath(moduleName: string) {
|
|
567
569
|
const { resolve } = await import('import-meta-resolve')
|
|
568
570
|
|
|
569
|
-
const scriptPath =
|
|
571
|
+
const scriptPath = resolve(moduleName, import.meta.url)
|
|
570
572
|
|
|
571
573
|
const { fileURLToPath } = await import('url')
|
|
572
574
|
|
|
573
575
|
return fileURLToPath(scriptPath)
|
|
574
576
|
}
|
|
577
|
+
|
|
578
|
+
export async function runOperationWithRetries<R>(
|
|
579
|
+
operationFunc: () => Promise<R>,
|
|
580
|
+
logger: Logger,
|
|
581
|
+
opreationName = "Operation",
|
|
582
|
+
delayBetweenRetries = 2000,
|
|
583
|
+
maxRetries = 200) {
|
|
584
|
+
|
|
585
|
+
for (let retryIndex = 1; retryIndex <= maxRetries; retryIndex++) {
|
|
586
|
+
try {
|
|
587
|
+
const result = await operationFunc()
|
|
588
|
+
|
|
589
|
+
return result
|
|
590
|
+
} catch (e: any) {
|
|
591
|
+
logger.setAsActiveLogger()
|
|
592
|
+
|
|
593
|
+
logger.logTitledMessage(`Error`, e.message, chalk.redBright)
|
|
594
|
+
logger.log(``)
|
|
595
|
+
logger.logTitledMessage(`${opreationName} failed`, `Trying again in ${delayBetweenRetries}ms..`, chalk.redBright)
|
|
596
|
+
|
|
597
|
+
await delay(delayBetweenRetries)
|
|
598
|
+
|
|
599
|
+
logger.log(``)
|
|
600
|
+
logger.logTitledMessage(`Starting retry attempt`, `${retryIndex} / ${maxRetries}`, chalk.yellowBright)
|
|
601
|
+
logger.log(``)
|
|
602
|
+
|
|
603
|
+
logger.unsetAsActiveLogger()
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
throw new Error(`${opreationName} failed after ${maxRetries} retry attempts`)
|
|
608
|
+
}
|