@gjsify/spiel-native 0.0.0-stage → 0.64.11
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/README.md +186 -2
- package/lib/esm/_virtual/_rolldown/runtime.js +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/namespace.js +0 -0
- package/lib/types/index.d.ts +58 -0
- package/lib/types/namespace.d.ts +85 -0
- package/meson.build +208 -0
- package/package.json +91 -5
- package/src/c/spiel.map +17 -0
- package/src/ts/index.ts +285 -0
- package/src/ts/namespace.ts +110 -0
- package/subprojects/libspeechprovider.wrap +23 -0
- package/subprojects/libspiel.wrap +19 -0
- package/test/check-elf-deps.py +74 -0
- package/test/load-typelib.gjs.js +59 -0
- package/test/speak-fakesink.gjs.js +83 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// THE LIVE END-TO-END CHECK — the one `load-typelib.gjs.js` deliberately does
|
|
2
|
+
// not do: find the speech providers on this session bus, synthesise one
|
|
3
|
+
// utterance and wait for `utterance-finished`.
|
|
4
|
+
//
|
|
5
|
+
// OPT-IN, behind GJSIFY_SPIEL_LIVE=1 (meson registers it either way; without the
|
|
6
|
+
// variable it exits 77 = skip). Two reasons, both about what it does to the
|
|
7
|
+
// machine running it:
|
|
8
|
+
//
|
|
9
|
+
// · It D-BUS-ACTIVATES every `*.Speech.Provider` on the bus — real daemons,
|
|
10
|
+
// started by a test run.
|
|
11
|
+
// · Its answer depends on which providers are installed, so it is a
|
|
12
|
+
// MEASUREMENT of a host, not an assertion about this build. A CI runner with
|
|
13
|
+
// no provider is not a failure; see README.md § Provider discovery for the
|
|
14
|
+
// numbers this produced here.
|
|
15
|
+
//
|
|
16
|
+
// NO AUDIBLE OUTPUT: `Speaker:sink` is set to a `fakesink` before `speak()` is
|
|
17
|
+
// ever called, so the synthesised audio is discarded instead of played. That
|
|
18
|
+
// property is `introspectable="0"` in the GIR, which means `speaker.sink = el`
|
|
19
|
+
// assigns a plain JS property and the pipeline keeps its default autoaudiosink —
|
|
20
|
+
// i.e. the WRONG spelling is silent about being wrong and loud about everything
|
|
21
|
+
// else. `set_property` is the only one that works.
|
|
22
|
+
|
|
23
|
+
import GLib from 'gi://GLib?version=2.0';
|
|
24
|
+
import Gst from 'gi://Gst?version=1.0';
|
|
25
|
+
import Spiel from 'gi://Spiel?version=1.0';
|
|
26
|
+
import System from 'system';
|
|
27
|
+
|
|
28
|
+
if (GLib.getenv('GJSIFY_SPIEL_LIVE') !== '1') {
|
|
29
|
+
console.log('speak-fakesink: skipped (set GJSIFY_SPIEL_LIVE=1 to run against this session bus)');
|
|
30
|
+
System.exit(77);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
Gst.init(null);
|
|
34
|
+
|
|
35
|
+
const speaker = Spiel.Speaker.new_sync(null);
|
|
36
|
+
|
|
37
|
+
const sink = Gst.ElementFactory.make('fakesink', 'gjsify-spiel-silence');
|
|
38
|
+
if (sink === null) throw new Error('gstreamer has no `fakesink` — install gstreamer1-plugins-base/core');
|
|
39
|
+
speaker.set_property('sink', sink);
|
|
40
|
+
|
|
41
|
+
const providers = speaker.providers;
|
|
42
|
+
const voices = speaker.voices;
|
|
43
|
+
console.log(`providers on this session bus: ${providers.get_n_items()}`);
|
|
44
|
+
for (let i = 0; i < providers.get_n_items(); i++) {
|
|
45
|
+
// `identifier`, not `well-known-name`: the latter is deprecated since 1.0.4
|
|
46
|
+
// and reading it prints a GJS deprecation warning. Same bus name either way.
|
|
47
|
+
const provider = providers.get_item(i);
|
|
48
|
+
console.log(` ${provider.identifier} — ${provider.name} (${provider.voices.get_n_items()} voices)`);
|
|
49
|
+
}
|
|
50
|
+
console.log(`voices: ${voices.get_n_items()}`);
|
|
51
|
+
|
|
52
|
+
if (voices.get_n_items() === 0) {
|
|
53
|
+
console.log('speak-fakesink: no voices on this bus — nothing to synthesise (not a failure)');
|
|
54
|
+
System.exit(77);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const loop = new GLib.MainLoop(null, false);
|
|
58
|
+
let failure = null;
|
|
59
|
+
|
|
60
|
+
speaker.connect('utterance-started', () => console.log(' utterance-started'));
|
|
61
|
+
speaker.connect('utterance-error', (_s, _u, error) => {
|
|
62
|
+
failure = error?.message ?? 'utterance-error with no message';
|
|
63
|
+
loop.quit();
|
|
64
|
+
});
|
|
65
|
+
speaker.connect('utterance-finished', () => {
|
|
66
|
+
console.log(' utterance-finished');
|
|
67
|
+
loop.quit();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// A hard stop, because every interesting failure here is a HANG: a provider
|
|
71
|
+
// that was activated and never answers leaves the loop running forever, and a
|
|
72
|
+
// test that never ends is indistinguishable from one that is slow.
|
|
73
|
+
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 30, () => {
|
|
74
|
+
failure = 'no utterance-finished within 30s';
|
|
75
|
+
loop.quit();
|
|
76
|
+
return GLib.SOURCE_REMOVE;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
speaker.speak(new Spiel.Utterance({ text: 'Gjsify prebuild check.' }));
|
|
80
|
+
loop.run();
|
|
81
|
+
|
|
82
|
+
if (failure !== null) throw new Error(`speak-fakesink: ${failure}`);
|
|
83
|
+
console.log('speak-fakesink: synthesised one utterance into a fakesink');
|