@atmosx/event-product-parser 3.0.62 → 3.0.75
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/.github/docs/docs-functions.md +1 -1
- package/.github/docs/docs-general-configurations.md +1 -11
- package/.github/docs/docs-integrations.md +3 -2
- package/README.md +10 -8
- package/dist/cjs/index.cjs +24482 -7207
- package/dist/esm/index.mjs +24275 -7003
- package/package.json +56 -47
- package/pnpm-workspace.yaml +4 -0
- package/src/bootstrap.ts +65 -48
- package/src/{@building → building}/CreateEvent.ts +22 -24
- package/src/{@building → building}/GetCleanedEvent.ts +2 -2
- package/src/{@building → building}/GetEventAttachments.ts +14 -12
- package/src/building/GetEventDirection.ts +28 -0
- package/src/{@building → building}/GetEventEnhancedName.ts +5 -8
- package/src/{@building → building}/GetEventGeometry.ts +19 -13
- package/src/{@building → building}/GetEventHeader.ts +13 -13
- package/src/{@building → building}/GetEventNodes.ts +22 -20
- package/src/{@building → building}/GetEventOffice.ts +13 -13
- package/src/building/GetEventPopulation.ts +58 -0
- package/src/building/GetEventProperties.ts +106 -0
- package/src/{@building → building}/GetEventSignature.ts +9 -9
- package/src/{@building → building}/GetEventTags.ts +3 -3
- package/src/building/GetEventTheme.ts +26 -0
- package/src/building/GetEventTracking.ts +64 -0
- package/src/components/audio/GenerateAudioMessage.ts +149 -0
- package/src/{@modules/@eas → components/audio/components}/GetCleanDescription.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetFloatPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetMergedPCM16.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetPCM16.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/GetPCMToFloat.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/GetSampledPCM16.ts +14 -8
- package/src/{@modules/@eas → components/audio/components}/GetTTS.ts +17 -10
- package/src/{@modules/@eas → components/audio/components}/GetWavPCM16.ts +7 -7
- package/src/{@modules/@eas → components/audio/components}/SetAFSK.ts +13 -8
- package/src/{@modules/@eas → components/audio/components}/SetAsciiToBits.ts +2 -2
- package/src/{@modules/@eas → components/audio/components}/SetAttentionTone.ts +11 -6
- package/src/{@modules/@eas → components/audio/components}/SetNoise.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetRadioEffect.ts +12 -7
- package/src/{@modules/@eas → components/audio/components}/SetSameHeader.ts +22 -14
- package/src/{@modules/@utilities/SetWarning.ts → components/database/CreateQuery.ts} +18 -13
- package/src/{@modules/@database → components/database}/GetCachedEvents.ts +18 -15
- package/src/components/database/ImportBoundaries.ts +168 -0
- package/src/{@modules/@database → components/database}/ImportBroadcastify.ts +14 -24
- package/src/components/database/ImportCities.ts +87 -0
- package/src/{@modules/@database → components/database}/ImportShapefiles.ts +23 -26
- package/src/{@modules/@database → components/database}/ImportStanza.ts +15 -19
- package/src/components/database/InitializeDatabase.ts +71 -0
- package/src/components/images/GenerateGraphic.ts +242 -0
- package/src/components/images/components/CreateRectangle.ts +22 -0
- package/src/components/images/components/CreateText.ts +22 -0
- package/src/components/images/modules/CreateSVG.ts +37 -0
- package/src/components/images/modules/GetGeographicalBoundaries.ts +72 -0
- package/src/components/images/modules/GetGeographicalCities.ts +58 -0
- package/src/components/images/modules/GetGeographicalEvents.ts +48 -0
- package/src/components/images/modules/GetGeometryBounds.ts +82 -0
- package/src/components/images/modules/GetParsedBoundary.ts +58 -0
- package/src/components/images/modules/GetSVGPath.ts +53 -0
- package/src/components/images/modules/NormalizePolygon.ts +57 -0
- package/src/{@modules/@stanza → components/stanza}/GetAwipsType.ts +16 -17
- package/src/{@modules/@stanza → components/stanza}/ValidateStanza.ts +27 -15
- package/src/{@modules/@utilities → components/utilities}/CreateHttp.ts +26 -26
- package/src/{@parsers/@text → components/utilities}/GetEmbededText.ts +8 -6
- package/src/{@modules/@utilities → components/utilities}/GetFormattedTime.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetLatestIssuance.ts +2 -2
- package/src/{@modules/@utilities → components/utilities}/GetMatched.ts +10 -5
- package/src/{@modules/@utilities → components/utilities}/GetShapeNearestPoint.ts +24 -19
- package/src/{@parsers/@text → components/utilities}/GetStringText.ts +9 -9
- package/src/components/utilities/GetUnionPolygon.ts +36 -0
- package/src/components/utilities/QueueManager.ts +70 -0
- package/src/components/utilities/SetCronSchedule.ts +106 -0
- package/src/{@modules/@utilities → components/utilities}/SetDebug.ts +12 -12
- package/src/components/utilities/SetEventEmit.ts +42 -0
- package/src/{@modules/@utilities → components/utilities}/SetSettings.ts +7 -7
- package/src/{@modules/@utilities → components/utilities}/SetSleep.ts +5 -5
- package/src/components/utilities/SetTimeoutAction.ts +64 -0
- package/src/components/utilities/SetWarning.ts +47 -0
- package/src/{@modules/@xmpp → components/xmpp}/DeployXMPP.ts +20 -20
- package/src/{@core/CreateListener.ts → components/xmpp/ErrorXMPP.ts} +8 -5
- package/src/{@modules/@xmpp → components/xmpp}/OfflineXMPP.ts +13 -13
- package/src/{@modules/@xmpp → components/xmpp}/OnlineXMPP.ts +18 -18
- package/src/components/xmpp/ReconnectXMPP.ts +64 -0
- package/src/{@modules/@xmpp → components/xmpp}/StanzaXMPP.ts +25 -25
- package/src/{@core → core}/ClearEvents.ts +9 -9
- package/src/{@core → core}/GetEvents.ts +4 -4
- package/src/{@core → core}/GetNodes.ts +4 -4
- package/src/{@core → core}/GetRandomEvent.ts +4 -4
- package/src/{@core → core}/GetVersion.ts +4 -4
- package/src/{@core → core}/ManualEvent.ts +23 -24
- package/src/{@core → core}/QueryStanza.ts +12 -11
- package/src/core/SetNode.ts +87 -0
- package/src/{@core → core}/StartService.ts +21 -20
- package/src/{@core → core}/StopService.ts +10 -10
- package/src/{@enums → enums}/AWIPS.ts +2 -2
- package/src/{@enums → enums}/Actions.ts +2 -2
- package/src/{@enums → enums}/Cancellation.ts +2 -2
- package/src/{@enums → enums}/Causes.ts +2 -2
- package/src/{@enums → enums}/Correlations.ts +2 -2
- package/src/{@enums → enums}/Enhanced.ts +4 -3
- package/src/{@enums → enums}/Events.ts +2 -2
- package/src/{@enums → enums}/Expressions.ts +3 -3
- package/src/{@enums → enums}/GlobalFilter.ts +2 -2
- package/src/{@enums → enums}/Hail.ts +2 -2
- package/src/{@enums → enums}/ICAO.ts +2 -2
- package/src/{@enums → enums}/Matches.ts +8 -3
- package/src/{@enums → enums}/Products.ts +2 -2
- package/src/{@enums → enums}/Records.ts +2 -2
- package/src/{@enums → enums}/Severity.ts +2 -2
- package/src/{@enums → enums}/Shapefiles.ts +2 -2
- package/src/{@enums → enums}/States.ts +68 -4
- package/src/{@enums → enums}/Status.ts +2 -2
- package/src/{@enums → enums}/Strings.ts +2 -2
- package/src/{@enums → enums}/Tags.ts +9 -4
- package/src/{@enums → enums}/Testing.ts +2 -2
- package/src/enums/Themes.ts +70 -0
- package/src/events/ParseAPI.ts +133 -0
- package/src/{@events → events}/ParseText.ts +24 -22
- package/src/{@events → events}/ParseUGC.ts +27 -26
- package/src/{@events → events}/ParseVTEC.ts +38 -37
- package/src/index.ts +57 -37
- package/src/{@manager → manager}/MakeEvents.ts +38 -47
- package/src/manager/RemoveEvent.ts +74 -0
- package/src/{@manager → manager}/SetHash.ts +18 -13
- package/src/{@manager → manager}/UpdateEvents.ts +12 -12
- package/src/{@manager → manager}/UpdateNode.ts +14 -14
- package/src/{@manager → manager}/ValidateEvents.ts +55 -45
- package/src/{@parsers/@hvtec → parsers/hvtec}/HVExtract.ts +11 -11
- package/src/{@parsers/@text → parsers/text}/GetDescriptionFromProduct.ts +20 -21
- package/src/parsers/text/GetPolygonFromProduct.ts +71 -0
- package/src/{@parsers/@text → parsers/text}/GetTextFromProduct.ts +12 -12
- package/src/parsers/ugc/GetCache.ts +24 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetExpiry.ts +2 -2
- package/src/{@parsers/@ugc/GetUGCHeader.ts → parsers/ugc/GetHeader.ts} +4 -4
- package/src/{@parsers/@ugc → parsers/ugc}/GetLocations.ts +10 -10
- package/src/parsers/ugc/GetZonePolygon.ts +73 -0
- package/src/{@parsers/@ugc → parsers/ugc}/GetZones.ts +3 -3
- package/src/{@parsers/@ugc → parsers/ugc}/SetCache.ts +13 -8
- package/src/{@parsers/@ugc → parsers/ugc}/UGCExtract.ts +14 -14
- package/src/{@parsers/@pvtec → parsers/vtec}/GetExpiry.ts +2 -2
- package/src/parsers/vtec/VTECExtract.ts +49 -0
- package/src/{@types → static}/Attributes.ts +2 -3
- package/src/{@types → static}/Event.ts +8 -7
- package/src/{@types → static}/Properties.ts +17 -3
- package/src/{@types → static}/Stanza.ts +2 -2
- package/src/tasks/CreateTasks.ts +116 -0
- package/src/tasks/TaskGenerateJSON.ts +34 -0
- package/src/tasks/TaskGenerateText.ts +34 -0
- package/src/tasks/TaskSendNTFY.ts +95 -0
- package/src/tasks/TaskSendWebhook.ts +107 -0
- package/src/{@types → types}/Actions.ts +3 -3
- package/src/{@types → types}/HVTEC.ts +6 -6
- package/src/{@types → types}/Hash.ts +5 -5
- package/src/types/Nodes.ts +29 -0
- package/src/{@types → types}/Settings.ts +17 -8
- package/src/{@types → types}/StanzaCompiled.ts +15 -15
- package/src/{@types → types}/UGC.ts +5 -5
- package/src/{@modules/@utilities/GetSettings.ts → types/VTEC.ts} +12 -7
- package/tools/build.js +47 -0
- package/tsconfig.json +28 -1
- package/src/@building/GetEventProperties.ts +0 -96
- package/src/@building/GetEventTracking.ts +0 -68
- package/src/@core/SetNode.ts +0 -81
- package/src/@events/ParseAPI.ts +0 -117
- package/src/@manager/RemoveEvent.ts +0 -70
- package/src/@manager/Tasks.ts +0 -246
- package/src/@modules/@database/InitializeDatabase.ts +0 -59
- package/src/@modules/@eas/GenerateEASMessage.ts +0 -144
- package/src/@modules/@utilities/SetCronSchedule.ts +0 -94
- package/src/@modules/@utilities/SetEventEmit.ts +0 -41
- package/src/@modules/@utilities/SetListener.ts +0 -30
- package/src/@modules/@utilities/SetTimeoutAction.ts +0 -64
- package/src/@modules/@xmpp/ErrorXMPP.ts +0 -27
- package/src/@modules/@xmpp/ReconnectXMPP.ts +0 -64
- package/src/@parsers/@pvtec/VTECExtract.ts +0 -49
- package/src/@parsers/@text/GetPolygonFromProduct.ts +0 -53
- package/src/@parsers/@text/GetXML.ts +0 -61
- package/src/@parsers/@ugc/GetCache.ts +0 -24
- package/src/@parsers/@ugc/GetZonePolygon.ts +0 -111
- package/src/@types/VTEC.ts +0 -30
- package/tsup.config.ts +0 -16
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeAttributes } from "
|
|
21
|
-
import {
|
|
22
|
-
import { EnumICAO } from "
|
|
20
|
+
import { TypeAttributes } from "StaticTypes/Attributes"
|
|
21
|
+
import { TypeVTEC } from "Types/VTEC"
|
|
22
|
+
import { EnumICAO } from "@Enums/ICAO"
|
|
23
23
|
|
|
24
24
|
interface GetOfficeOptions {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
Attributes: TypeAttributes
|
|
26
|
+
Organization: string
|
|
27
|
+
VTEC: TypeVTEC
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
interface GetOfficeResponse {
|
|
@@ -32,11 +32,11 @@ interface GetOfficeResponse {
|
|
|
32
32
|
name: string | null
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const GetEventOffice = (
|
|
36
|
-
const office =
|
|
37
|
-
?
|
|
38
|
-
(
|
|
39
|
-
(Array.isArray(
|
|
35
|
+
export const GetEventOffice = ({ Attributes, Organization, VTEC }: GetOfficeOptions): GetOfficeResponse => {
|
|
36
|
+
const office = VTEC != null
|
|
37
|
+
? VTEC?.Tracking?.split(`.`)[0] : (Attributes?.cccc ??
|
|
38
|
+
(Organization != null ?
|
|
39
|
+
(Array.isArray(Organization) ? Organization?.[0] : Organization)
|
|
40
40
|
: null));
|
|
41
41
|
const name = EnumICAO?.[office] ?? null;
|
|
42
42
|
return { office, name };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ _ _ __ __
|
|
3
|
+
/\ | | | | (_) \ \ / /
|
|
4
|
+
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
+
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
+
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
+
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
+
| |
|
|
9
|
+
|_|
|
|
10
|
+
|
|
11
|
+
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
+
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
+
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { TypeCities } from "StaticTypes/Properties"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { CreateQuery } from "@Database/CreateQuery"
|
|
23
|
+
import { NormalizePolygon } from "@ImageModules/NormalizePolygon"
|
|
24
|
+
|
|
25
|
+
interface GetEventPopulationResponse {
|
|
26
|
+
population: number
|
|
27
|
+
cities: TypeCities[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const GetEventPopulation = (geometry: GeoJSON.Polygon | GeoJSON.MultiPolygon | null): GetEventPopulationResponse => {
|
|
31
|
+
const coordinates = geometry?.coordinates;
|
|
32
|
+
if (!coordinates || !Array.isArray(coordinates) || coordinates.length === 0 || !Bootstrap.Settings.GlobalSettings.CensusPopulationData) {
|
|
33
|
+
return { population: 0, cities: [] };
|
|
34
|
+
}
|
|
35
|
+
const normalized = NormalizePolygon(geometry) as GeoJSON.Polygon | GeoJSON.MultiPolygon;
|
|
36
|
+
const points = normalized.type === `Polygon` ? normalized.coordinates[0] : normalized.coordinates.flatMap(polygon => polygon[0]);
|
|
37
|
+
const latitudes = points.map(([lon, lat]) => lat);
|
|
38
|
+
const longitudes = points.map(([lon, lat]) => lon);
|
|
39
|
+
const minLat = Math.min(...latitudes);
|
|
40
|
+
const maxLat = Math.max(...latitudes);
|
|
41
|
+
const minLon = Math.min(...longitudes);
|
|
42
|
+
const maxLon = Math.max(...longitudes);
|
|
43
|
+
const A = CreateQuery({
|
|
44
|
+
Query: `SELECT * FROM cities WHERE LAT BETWEEN ? AND ? AND LON BETWEEN ? AND ?`,
|
|
45
|
+
Parameters: [ minLat, maxLat, minLon, maxLon ]
|
|
46
|
+
});
|
|
47
|
+
const population = A.reduce((acc: number, city: any) => {
|
|
48
|
+
const census = Number(city.population);
|
|
49
|
+
return acc + (isNaN(census) ? 0 : census);
|
|
50
|
+
}, 0);
|
|
51
|
+
const cities = A.map((city: any) => ({
|
|
52
|
+
name: city.name,
|
|
53
|
+
state: city.state,
|
|
54
|
+
county: city.county.replace(/ County$/i, ``),
|
|
55
|
+
population: Number(city.population)
|
|
56
|
+
}));
|
|
57
|
+
return { population, cities };
|
|
58
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ _ _ __ __
|
|
3
|
+
/\ | | | | (_) \ \ / /
|
|
4
|
+
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
+
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
+
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
+
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
+
| |
|
|
9
|
+
|_|
|
|
10
|
+
|
|
11
|
+
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
+
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
+
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { TypeEventProperties } from "StaticTypes/Properties"
|
|
21
|
+
import { TypeAttributes } from "StaticTypes/Attributes"
|
|
22
|
+
import { TypeUGC } from "Types/UGC"
|
|
23
|
+
import { TypeVTEC } from "Types/VTEC"
|
|
24
|
+
import { EnumExpressions } from "@Enums/Expressions"
|
|
25
|
+
import { GetDescriptionFromProduct } from "@ParsingText/GetDescriptionFromProduct"
|
|
26
|
+
import { GetPolygonFromProduct } from "@ParsingText/GetPolygonFromProduct"
|
|
27
|
+
import { GetTextFromProduct } from "@ParsingText/GetTextFromProduct"
|
|
28
|
+
import { GetEventOffice } from "@Building/GetEventOffice"
|
|
29
|
+
import { GetEventTags } from "@Building/GetEventTags"
|
|
30
|
+
import { GetEventDirection } from "@Building/GetEventDirection"
|
|
31
|
+
|
|
32
|
+
interface GetEventPropertiesOptions {
|
|
33
|
+
Message: string
|
|
34
|
+
Attributes: TypeAttributes
|
|
35
|
+
UGC?: TypeUGC
|
|
36
|
+
VTEC?: TypeVTEC
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const GetEventProperties = ({ Message, Attributes, UGC, VTEC }: GetEventPropertiesOptions): TypeEventProperties => {
|
|
40
|
+
const organization = Message.match(EnumExpressions.wmo)?.[0] ?? null
|
|
41
|
+
const polygons = GetPolygonFromProduct(Message)
|
|
42
|
+
const properties = {
|
|
43
|
+
locations: UGC?.Locations?.join(`; `) ?? null,
|
|
44
|
+
locations_array: UGC?.Locations ?? [],
|
|
45
|
+
regions: [...new Set(
|
|
46
|
+
UGC?.Zones
|
|
47
|
+
?.map((location: string) => location.match(/^([A-Z]{2})[CZ](\d{3})$/)?.[1])
|
|
48
|
+
.filter(Boolean) ?? []
|
|
49
|
+
)],
|
|
50
|
+
regions_string: (() => {
|
|
51
|
+
const abbrs = [...new Set(UGC?.Zones?.map((l: string) => l.match(/^([A-Z]{2})[CZ](\d{3})$/)?.[1]).filter(Boolean) ?? [])];
|
|
52
|
+
return abbrs.length ? abbrs.join(`-`) : null;
|
|
53
|
+
})(),
|
|
54
|
+
description: GetDescriptionFromProduct({ Message: Message, Handle: VTEC?.Raw ?? null }),
|
|
55
|
+
attributes: Attributes,
|
|
56
|
+
geocode: {
|
|
57
|
+
office: GetEventOffice({ Attributes: Attributes, Organization: organization, VTEC: VTEC }),
|
|
58
|
+
organization: organization,
|
|
59
|
+
ugc: UGC?.Zones ?? [],
|
|
60
|
+
census: {},
|
|
61
|
+
polygon: polygons.length > 0 ? Buffer.from(JSON.stringify([polygons])).toString('base64') : null,
|
|
62
|
+
polygon_generated: polygons.length > 0 ? true : false
|
|
63
|
+
},
|
|
64
|
+
parameters: {
|
|
65
|
+
tags: GetEventTags(Message),
|
|
66
|
+
instructions: GetTextFromProduct({ Message: Message, Find: [`For your protection`, `do not`, `use extreme caution`], Append: `...`, Removal: [`.`]}) ?? null,
|
|
67
|
+
source: GetTextFromProduct({ Message: Message, Find: [`SOURCE...`], Removal: [`.`]}) ?? null,
|
|
68
|
+
hazards: GetTextFromProduct({ Message: Message, Find: [`HAZARD...`], Removal: [`.`]}) ?? null,
|
|
69
|
+
impacts: GetTextFromProduct({ Message: Message, Find: [`IMPACT...`], Removal: [`.`]}) ?? null,
|
|
70
|
+
estimated_hail_size: GetTextFromProduct({ Message: Message, Find: [`MAX HAIL SIZE...`, `HAIL...`], Removal: ['in']}) ?? null,
|
|
71
|
+
estimated_wind_gusts: GetTextFromProduct({ Message: Message, Find: [`MAX WIND GUST...`, `WIND...`]}) ?? null,
|
|
72
|
+
direction: GetEventDirection(Message) ?? null,
|
|
73
|
+
damage_threat: GetTextFromProduct({ Message: Message, Find: [`DAMAGE THREAT...`], Removal: []}) ?? null,
|
|
74
|
+
tornado_threat: GetTextFromProduct({ Message: Message, Find: [`TORNADO...`, `WATERSPOUT...`] }) ?? null,
|
|
75
|
+
flood_threat: GetTextFromProduct({ Message: Message, Find: [`FLASH FLOOD...`]}) ?? null,
|
|
76
|
+
wind_threat: GetTextFromProduct({ Message: Message, Find: [`WIND THREAT...`]}) ?? null,
|
|
77
|
+
hail_threat: GetTextFromProduct({ Message: Message, Find: [`HAIL THREAT...`], Removal: []}) ?? null,
|
|
78
|
+
},
|
|
79
|
+
discussion_parameters: {
|
|
80
|
+
discussion_number: GetTextFromProduct({ Message: Message, Find: [`Mesoscale Discussion `], Removal: [`Mesoscale Discussion`, `Number`, `...`] })?.toString()?.padStart(4, "0") ?? null,
|
|
81
|
+
discussion_concerning: GetTextFromProduct({ Message: Message, Find: [`Concerning...`] }) ?? null,
|
|
82
|
+
discussion_max_tornado: GetTextFromProduct({ Message: Message, Find: [`MOST PROBABLE PEAK TORNADO INTENSITY...`] }) ?? null,
|
|
83
|
+
discussion_max_hail: GetTextFromProduct({ Message: Message, Find: [`MOST PROBABLE PEAK HAIL SIZE...`] }) ?? null,
|
|
84
|
+
discussion_max_wind: GetTextFromProduct({ Message: Message, Find: [`MOST PROBABLE PEAK WIND GUST...`] }) ?? null,
|
|
85
|
+
discussion_watch_issuance: GetTextFromProduct({ Message: Message, Find: [`Probability of Watch Issuance...`], Removal: [`percent`]}) ?? null,
|
|
86
|
+
},
|
|
87
|
+
watch_parameters: {
|
|
88
|
+
watch_number: VTEC?.Watch ? ( GetTextFromProduct({ Message: Message, Find: [`ITIES FOR`, `UPDATE FOR`, `Watch Number `], Removal: [`%`, `<`, `:`] })?.replace(/(WT|WS|)/g, '')?.trim()?.toString()?.padStart(4, "0") ?? VTEC?.Tracking?.slice(-4)?.toString()?.padStart(4, "0") ?? null) : null,
|
|
89
|
+
watch_type: Message.includes(`TORNADO WATCH`) ? `Tornado` : Message.includes(`SEVERE`) ? `Severe` : null,
|
|
90
|
+
additional_tornadoes_probability: GetTextFromProduct({ Message: Message, Find: [`PROB OF 2 OR MORE TORNADOES`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
91
|
+
strong_tornadoes_probability: GetTextFromProduct({ Message: Message, Find: [`PROB OF 1 OR MORE STRONG /EF2-EF5/ TORNADOES`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
92
|
+
severe_wind_probability: GetTextFromProduct({ Message: Message, Find: [`PROB OF 10 OR MORE SEVERE WIND EVENTS`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
93
|
+
severe_hail_probability: GetTextFromProduct({ Message: Message, Find: [`PROB OF 10 OR MORE SEVERE HAIL EVENTS`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
94
|
+
hail_2in_probability: GetTextFromProduct({ Message: Message, Find: [`PROB OF 1 OR MORE HAIL EVENTS >= 2 INCHES`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
95
|
+
combined_hail_wind_probability: GetTextFromProduct({ Message: Message, Find: [`PROB OF 6 OR MORE COMBINED SEVERE HAIL/WIND EVENTS`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
96
|
+
max_hail_in: GetTextFromProduct({ Message: Message, Find: [`MAX HAIL /INCHES/`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
97
|
+
max_wind_surface: GetTextFromProduct({ Message: Message, Find: [`MAX WIND GUSTS SURFACE /KNOTS/`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
98
|
+
max_tops_x100feet: GetTextFromProduct({ Message: Message, Find: [`MAX TOPS /X 100 FEET/`], Removal: [`%`, `<`, `:`] }) ?? null,
|
|
99
|
+
pds_watch: (GetTextFromProduct({ Message: Message, Find: [`PARTICULARLY DANGEROUS SITUATION`], Removal: [`%`, `<`, `:`] }) === `YES` ? true : null)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (isNaN(Number(properties.watch_parameters.watch_number))) {
|
|
103
|
+
properties.watch_parameters.watch_number = null
|
|
104
|
+
}
|
|
105
|
+
return properties;
|
|
106
|
+
}
|
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { TypeEvent } from "
|
|
21
|
-
import { EnumCorrelations } from "
|
|
22
|
-
import { EnumCancellation } from "
|
|
23
|
-
import { EnumTesting} from "
|
|
24
|
-
import { EnumProducts } from "
|
|
25
|
-
import { EnumHail } from "
|
|
20
|
+
import { TypeEvent } from "StaticTypes/Event"
|
|
21
|
+
import { EnumCorrelations } from "@Enums/Correlations"
|
|
22
|
+
import { EnumCancellation } from "@Enums/Cancellation"
|
|
23
|
+
import { EnumTesting} from "@Enums/Testing"
|
|
24
|
+
import { EnumProducts } from "@Enums/Products"
|
|
25
|
+
import { EnumHail } from "@Enums/Hail"
|
|
26
26
|
|
|
27
27
|
export const GetEventSignature = (event: TypeEvent): TypeEvent => {
|
|
28
28
|
const properties = event?.properties;
|
|
@@ -44,7 +44,7 @@ export const GetEventSignature = (event: TypeEvent): TypeEvent => {
|
|
|
44
44
|
properties.status_metadata = { ...properties.status_metadata, is_expired: true };
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
const getProduct = vtec?.
|
|
47
|
+
const getProduct = vtec?.Raw?.split(`.`)[0]?.replace(`/`, ``)
|
|
48
48
|
const isTestProduct = EnumProducts[getProduct] == `Test Product`
|
|
49
49
|
if (isTestProduct || EnumTesting.some(sig => properties.description?.toLowerCase().includes(sig.toLowerCase()) ?? properties?.parameters?.instructions?.toLowerCase().includes(sig.toLowerCase()))) {
|
|
50
50
|
properties.status_metadata = { ...properties.status_metadata, is_test: true }
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
import { EnumTags } from "
|
|
20
|
+
import { EnumTags } from "@Enums/Tags"
|
|
21
21
|
|
|
22
22
|
export const GetEventTags = (message: string): string[] => {
|
|
23
23
|
if (!message) return [];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ _ _ __ __
|
|
3
|
+
/\ | | | | (_) \ \ / /
|
|
4
|
+
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
+
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
+
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
+
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
+
| |
|
|
9
|
+
|_|
|
|
10
|
+
|
|
11
|
+
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
+
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
+
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { Bootstrap } from "@Bootstrap";
|
|
21
|
+
import { EnumThemes } from "@Enums/Themes"
|
|
22
|
+
import { GetMatched } from "@Utilities/GetMatched";
|
|
23
|
+
|
|
24
|
+
export const GetEventTheme = (Event: string): string => {
|
|
25
|
+
return Bootstrap.Settings.GlobalSettings.Themes.find(theme => GetMatched({Strings: [theme.Event], String: Event}))?.RGB ?? EnumThemes.find(theme => theme.Event === `Default`)?.RGB ?? `rgb(56, 72, 88)`;
|
|
26
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ _ _ __ __
|
|
3
|
+
/\ | | | | (_) \ \ / /
|
|
4
|
+
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
+
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
+
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
+
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
+
| |
|
|
9
|
+
|_|
|
|
10
|
+
|
|
11
|
+
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
+
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
+
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { TypeAttributes } from "StaticTypes/Attributes"
|
|
21
|
+
import { TypeEventProperties } from "StaticTypes/Properties"
|
|
22
|
+
import { TypeStanzaCompiled } from "Types/StanzaCompiled"
|
|
23
|
+
import { TypeVTEC } from "Types/VTEC"
|
|
24
|
+
|
|
25
|
+
interface GetTrackingOptions {
|
|
26
|
+
Type: `RAW` | `VTEC` | `API`
|
|
27
|
+
Stanza?: TypeStanzaCompiled
|
|
28
|
+
Attributes?: TypeAttributes
|
|
29
|
+
Properties?: TypeEventProperties
|
|
30
|
+
WMO?: {
|
|
31
|
+
Identifier: string
|
|
32
|
+
ID: string
|
|
33
|
+
}
|
|
34
|
+
VTEC?: TypeVTEC
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const GetEventTracking = ({ Type, Stanza, Attributes, Properties, WMO, VTEC }: GetTrackingOptions): string => {
|
|
38
|
+
if (Type === `RAW`) {
|
|
39
|
+
const getWatchNumber = Properties?.watch_parameters?.watch_number ?? null
|
|
40
|
+
if (getWatchNumber) {
|
|
41
|
+
return `${Properties.geocode.office.office}.${Stanza.Type.Prefix}.A.${getWatchNumber}`
|
|
42
|
+
}
|
|
43
|
+
return `${Properties.geocode.office.office}.${Attributes.ttaaii}.${Attributes.id.slice(-4).replace(`.`, ``) ?? '0'}`
|
|
44
|
+
}
|
|
45
|
+
if (Type === `VTEC`) {
|
|
46
|
+
return VTEC?.Tracking;
|
|
47
|
+
}
|
|
48
|
+
if (Type === `API`) {
|
|
49
|
+
if (VTEC) {
|
|
50
|
+
const vtecValue = Array.isArray(VTEC)
|
|
51
|
+
? VTEC[0].vtec : VTEC?.Raw;
|
|
52
|
+
const splitVTEC = vtecValue.split('.');
|
|
53
|
+
return `${splitVTEC[2]}.${splitVTEC[3]}.${splitVTEC[4]}.${splitVTEC[5]}`;
|
|
54
|
+
}
|
|
55
|
+
const wmoMatch = WMO?.Identifier?.match(/([A-Z]{4}\d{2})\s+([A-Z]{4})/);
|
|
56
|
+
const station = wmoMatch?.[2] ?? '---';
|
|
57
|
+
if (WMO?.ID) {
|
|
58
|
+
const idMatch = WMO?.ID.match(/([a-f0-9]+)\.(\d+)\.(\d+)$/);
|
|
59
|
+
return `${station}.${idMatch?.[0]?.replace(/\./g, '') ?? '---'}`;
|
|
60
|
+
}
|
|
61
|
+
const id = wmoMatch?.[1] ?? '---';
|
|
62
|
+
return `${station}.${id?.replace(/\./g, '') ?? '---'}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
_ _ _ __ __
|
|
3
|
+
/\ | | | | (_) \ \ / /
|
|
4
|
+
/ \ | |_ _ __ ___ ___ ___ _ __ | |__ ___ _ __ _ ___ \ V /
|
|
5
|
+
/ /\ \| __| '_ ` _ \ / _ \/ __| '_ \| '_ \ / _ \ '__| |/ __| > <
|
|
6
|
+
/ ____ \ |_| | | | | | (_) \__ \ |_) | | | | __/ | | | (__ / . \
|
|
7
|
+
/_/ \_\__|_| |_| |_|\___/|___/ .__/|_| |_|\___|_| |_|\___/_/ \_\
|
|
8
|
+
| |
|
|
9
|
+
|_|
|
|
10
|
+
|
|
11
|
+
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
|
+
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
|
+
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
|
+
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
|
+
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { TypeSettings } from "Types/Settings"
|
|
21
|
+
import { Bootstrap } from "@Bootstrap"
|
|
22
|
+
import { GetWavPCM16 } from "@AudioComponents/GetWavPCM16"
|
|
23
|
+
import { GetSampledPCM16 } from "@AudioComponents/GetSampledPCM16"
|
|
24
|
+
import { SetRadioEffect } from "@AudioComponents/SetRadioEffect"
|
|
25
|
+
import { SetSameHeader } from "@AudioComponents/SetSameHeader"
|
|
26
|
+
import { SetAttentionTone } from "@AudioComponents/SetAttentionTone"
|
|
27
|
+
import { GetMergedPCM16 } from "@AudioComponents/GetMergedPCM16"
|
|
28
|
+
import { SetNoise } from "@AudioComponents/SetNoise"
|
|
29
|
+
import { GetPCM16 } from "@AudioComponents/GetPCM16"
|
|
30
|
+
import { GetTTS } from "@AudioComponents/GetTTS"
|
|
31
|
+
import { GetCleanDescription } from "@AudioComponents/GetCleanDescription"
|
|
32
|
+
import { SetWarning } from "@Utilities/SetWarning"
|
|
33
|
+
import { SetDebug } from "@Utilities/SetDebug"
|
|
34
|
+
import { join } from "path"
|
|
35
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync, unlinkSync } from "fs"
|
|
36
|
+
import { execSync } from "child_process"
|
|
37
|
+
import { platform } from "os"
|
|
38
|
+
|
|
39
|
+
interface GenerateAudioMessageOptions {
|
|
40
|
+
Message: string
|
|
41
|
+
Header: string
|
|
42
|
+
Directory?: string
|
|
43
|
+
Title: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const GenerateAudioMessage = async ({ Message, Directory, Header, Title }: GenerateAudioMessageOptions): Promise<string> => {
|
|
47
|
+
const tick = performance.now()
|
|
48
|
+
const settings = Bootstrap.Settings as TypeSettings;
|
|
49
|
+
const prefix = settings.GlobalSettings.ArchiveSettings.AudioToneout;
|
|
50
|
+
let title = (Title ?? `${Math.random().toString(36).substring(2, 15)}-${Header.replace(/[^a-zA-Z0-9]/g, '')}`).replace(/[\\:*?"<>|]/g, "_").replace(/\s+/g, " ").trim();
|
|
51
|
+
if (!Message || !Header) {
|
|
52
|
+
SetWarning({
|
|
53
|
+
Title: `Audio`,
|
|
54
|
+
Message: `Message and header are required to generate an audio message.`
|
|
55
|
+
})
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
let buffTTS: Buffer;
|
|
59
|
+
let buffRadio: any;
|
|
60
|
+
let buffFull: any[] = [];
|
|
61
|
+
|
|
62
|
+
if (!Directory) {
|
|
63
|
+
SetWarning({
|
|
64
|
+
Title: `Audio`,
|
|
65
|
+
Message: `Audio directory is not set in the settings. Please set it to generate audio messages.`
|
|
66
|
+
});
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!existsSync(Directory)) {
|
|
71
|
+
mkdirSync(Directory, { recursive: true });
|
|
72
|
+
}
|
|
73
|
+
const tmpTTS = join(Directory, `/${title}-tts.wav`)
|
|
74
|
+
const outTTS = join(Directory, `/${title}.wav`)
|
|
75
|
+
const vPlatform = platform();
|
|
76
|
+
|
|
77
|
+
if (vPlatform === 'darwin') {
|
|
78
|
+
SetWarning({
|
|
79
|
+
Title: `Audio`,
|
|
80
|
+
Message: `Audio tone generation is not supported on macOS.`
|
|
81
|
+
});
|
|
82
|
+
return null
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
await new Promise<void>((resolve, reject) => {
|
|
87
|
+
const tMsg = GetCleanDescription(Message)
|
|
88
|
+
GetTTS({Text: tMsg, OutputPath: tmpTTS}).then(() => {
|
|
89
|
+
resolve();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
if (!existsSync(tmpTTS)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
buffTTS = readFileSync(tmpTTS);
|
|
96
|
+
const vWav = GetWavPCM16(buffTTS);
|
|
97
|
+
const vSamples = GetSampledPCM16({Int16: vWav.Samples, OriginalRate: vWav.SampleRate, TargetRate: 8000})
|
|
98
|
+
const vRadio = SetRadioEffect({Int16: vSamples, SampleRate: 8000});
|
|
99
|
+
|
|
100
|
+
if (existsSync(prefix)) {
|
|
101
|
+
let tBuffer = readFileSync(prefix);
|
|
102
|
+
let tWav = GetWavPCM16(tBuffer);
|
|
103
|
+
|
|
104
|
+
if (tWav == null) {
|
|
105
|
+
try {
|
|
106
|
+
const converted = join(Directory, `/${title}-tts-fixed.wav`)
|
|
107
|
+
execSync(`ffmpeg -y -i "${prefix}" -ar 8000 -ac 1 -sample_fmt s16 "${converted}"`, { stdio: 'ignore' })
|
|
108
|
+
if (existsSync(converted)) {
|
|
109
|
+
tBuffer = readFileSync(converted)
|
|
110
|
+
tWav = GetWavPCM16(tBuffer)
|
|
111
|
+
try { unlinkSync(converted) } catch {}
|
|
112
|
+
}
|
|
113
|
+
} catch (e) {}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (tWav == null) {
|
|
117
|
+
SetWarning({
|
|
118
|
+
Title: `EAS`,
|
|
119
|
+
Message: `Intro tone isn't a valid .WAV file or isn't in PCM 16-bit format. Converted attempt failed; please convert it then try again.`
|
|
120
|
+
})
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const tSamples = (tWav.SampleRate != 8000 ? GetSampledPCM16({Int16: tWav.Samples, OriginalRate: tWav.SampleRate, TargetRate: 8000}) : tWav.Samples)
|
|
125
|
+
buffRadio = SetRadioEffect({Int16: tSamples, SampleRate: 8000})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
buffFull = buffRadio != null ? [buffRadio, new Int16Array(Math.floor(0.5 * 8000))] : [];
|
|
129
|
+
buffFull.push(
|
|
130
|
+
SetSameHeader({ VTEC: Header, Repeats: 3, SampleRate: 8000, PreMarkSec: 1.1, GapSec: 0.5 }),
|
|
131
|
+
new Int16Array(Math.floor(0.5 * 8000)),
|
|
132
|
+
SetAttentionTone({ MS: 8, SampleRate: 8000 }),
|
|
133
|
+
new Int16Array(Math.floor(0.5 * 8000)),
|
|
134
|
+
vRadio
|
|
135
|
+
)
|
|
136
|
+
for (let i = 0; i < 3; i++) {
|
|
137
|
+
buffFull.push(SetSameHeader({ VTEC: Header, Repeats: 1, SampleRate: 8000, PreMarkSec: 0.5, GapSec: 0.1 }))
|
|
138
|
+
buffFull.push(new Int16Array(Math.floor(0.5 * 8000)));
|
|
139
|
+
}
|
|
140
|
+
const aSamples = GetMergedPCM16(buffFull);
|
|
141
|
+
const aFinal = SetNoise({ Int16: aSamples, NoiseLevel: 0.002 });
|
|
142
|
+
const aBuffer = GetPCM16({ Samples: Array.from(aFinal).map(v => ({ value: v })), SampleRate: 8000 });
|
|
143
|
+
writeFileSync(outTTS, aBuffer)
|
|
144
|
+
try{ unlinkSync(tmpTTS) } catch {}
|
|
145
|
+
SetDebug({ Title: `GenerateEASMessage`, Message: `${Math.round(performance.now() - tick)}ms` })
|
|
146
|
+
return outTTS;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
@@ -11,19 +11,24 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
interface GetPCM16Options {
|
|
22
|
+
Samples: Record<string, number>[]
|
|
23
|
+
SampleRate: number
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const GetPCM16 = ({ Samples, SampleRate }: GetPCM16Options): Buffer => {
|
|
22
27
|
let o = 0;
|
|
23
28
|
const bytesPerSample = 2;
|
|
24
29
|
const blockAlign = 1 * bytesPerSample;
|
|
25
|
-
const byteRate =
|
|
26
|
-
const subchunk2Size =
|
|
30
|
+
const byteRate = SampleRate * blockAlign;
|
|
31
|
+
const subchunk2Size = Samples.length * bytesPerSample;
|
|
27
32
|
const chunkSize = 36 + subchunk2Size;
|
|
28
33
|
const buffer = Buffer.alloc(44 + subchunk2Size);
|
|
29
34
|
|
|
@@ -35,7 +40,7 @@ export const GetPCM16 = (samples: Record<string, number>[], sampleRate: number):
|
|
|
35
40
|
buffer.writeUInt32LE(16, o); o += 4;
|
|
36
41
|
buffer.writeUInt16LE(1, o); o += 2;
|
|
37
42
|
buffer.writeUInt16LE(1, o); o += 2;
|
|
38
|
-
buffer.writeUInt32LE(
|
|
43
|
+
buffer.writeUInt32LE(SampleRate, o); o += 4;
|
|
39
44
|
buffer.writeUInt32LE(byteRate, o); o += 4;
|
|
40
45
|
buffer.writeUInt16LE(blockAlign, o); o += 2;
|
|
41
46
|
buffer.writeUInt16LE(16, o); o += 2;
|
|
@@ -43,8 +48,8 @@ export const GetPCM16 = (samples: Record<string, number>[], sampleRate: number):
|
|
|
43
48
|
buffer.write("data", o); o += 4;
|
|
44
49
|
buffer.writeUInt32LE(subchunk2Size, o); o += 4;
|
|
45
50
|
|
|
46
|
-
for (let i = 0; i <
|
|
47
|
-
buffer.writeInt16LE(
|
|
51
|
+
for (let i = 0; i < Samples.length; i++, o += 2) {
|
|
52
|
+
buffer.writeInt16LE(Samples[i].value, o);
|
|
48
53
|
}
|
|
49
54
|
return buffer;
|
|
50
55
|
}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
@@ -11,24 +11,30 @@
|
|
|
11
11
|
Created with ♥ by the AtmosphericX Team (KiyoWx, StarflightWx, & CJ Ziegler)
|
|
12
12
|
Discord: https://atmosphericx-discord.scriptkitty.cafe
|
|
13
13
|
Ko-Fi: https://ko-fi.com/k3yomi
|
|
14
|
-
Documentation:
|
|
14
|
+
Documentation: https://atmosphericx.scriptkitty.cafe/documentation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Independent Package: @atmosx/event-product-parser
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
interface GetSampledPCM16Options {
|
|
22
|
+
Int16: Int16Array
|
|
23
|
+
OriginalRate: number
|
|
24
|
+
TargetRate: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const GetSampledPCM16 = ({ Int16, OriginalRate, TargetRate }: GetSampledPCM16Options): Int16Array => {
|
|
28
|
+
if (OriginalRate === TargetRate) return Int16;
|
|
29
|
+
const ratio = TargetRate / OriginalRate;
|
|
30
|
+
const outLen = Math.max(1, Math.round(Int16.length * ratio));
|
|
25
31
|
const out = new Int16Array(outLen);
|
|
26
32
|
for (let i = 0; i < outLen; i++) {
|
|
27
33
|
const pos = i / ratio;
|
|
28
34
|
const i0 = Math.floor(pos);
|
|
29
|
-
const i1 = Math.min(i0 + 1,
|
|
35
|
+
const i1 = Math.min(i0 + 1, Int16.length - 1);
|
|
30
36
|
const frac = pos - i0;
|
|
31
|
-
const v =
|
|
37
|
+
const v = Int16[i0] * (1 - frac) + Int16[i1] * frac;
|
|
32
38
|
out[i] = Math.round(v);
|
|
33
39
|
}
|
|
34
40
|
return out;
|