at 25.11-pre 3.0 kB view raw
1import ./make-test-python.nix ( 2 { lib, ... }: 3 let 4 port = 59126; 5 in 6 { 7 name = "marytts"; 8 meta.maintainers = with lib.maintainers; [ pluiedev ]; 9 10 nodes.machine = 11 { pkgs, ... }: 12 { 13 networking.firewall.enable = false; 14 networking.useDHCP = false; 15 16 services.marytts = { 17 enable = true; 18 inherit port; 19 20 voices = [ 21 (pkgs.fetchzip { 22 url = "https://github.com/marytts/voice-bits1-hsmm/releases/download/v5.2/voice-bits1-hsmm-5.2.zip"; 23 hash = "sha256-1nK+qZxjumMev7z5lgKr660NCKH5FDwvZ9sw/YYYeaA="; 24 }) 25 ]; 26 27 userDictionaries = [ 28 (pkgs.writeTextFile { 29 name = "userdict-en_US.txt"; 30 destination = "/userdict-en_US.txt"; 31 text = '' 32 amogus | @ - ' m @U - g @ s 33 Nixpkgs | n I k s - ' p { - k @ - dZ @ s 34 ''; 35 }) 36 ]; 37 }; 38 }; 39 40 testScript = '' 41 from xml.etree import ElementTree 42 from urllib.parse import urlencode 43 44 machine.wait_for_unit("marytts.service") 45 46 with subtest("Checking health of MaryTTS server"): 47 machine.wait_for_open_port(${toString port}) 48 assert 'Mary TTS server' in machine.succeed("curl 'localhost:${toString port}/version'") 49 50 with subtest("Generating example MaryXML"): 51 query = urlencode({ 52 'datatype': 'RAWMARYXML', 53 'locale': 'en_US', 54 }) 55 xml = machine.succeed(f"curl 'localhost:${toString port}/exampletext?{query}'") 56 root = ElementTree.fromstring(xml) 57 text = " ".join(root.itertext()).strip() 58 assert text == "Welcome to the world of speech synthesis!" 59 60 with subtest("Detecting custom voice"): 61 assert "bits1-hsmm" in machine.succeed("curl 'localhost:${toString port}/voices'") 62 63 with subtest("Finding user dictionary"): 64 query = urlencode({ 65 'INPUT_TEXT': 'amogus', 66 'INPUT_TYPE': 'TEXT', 67 'OUTPUT_TYPE': 'PHONEMES', 68 'LOCALE': 'en_US', 69 }) 70 phonemes = machine.succeed(f"curl 'localhost:${toString port}/process?{query}'") 71 phonemes_tree = ElementTree.fromstring(phonemes) 72 print([i.get('ph') for i in phonemes_tree.iter('{http://mary.dfki.de/2002/MaryXML}t')]) 73 assert ["@ - ' m @U - g @ s"] == [i.get('ph') for i in phonemes_tree.iter('{http://mary.dfki.de/2002/MaryXML}t')] 74 75 with subtest("Synthesizing"): 76 query = urlencode({ 77 'INPUT_TEXT': 'Nixpkgs is a collection of over 100,000 software packages that can be installed with the Nix package manager.', 78 'INPUT_TYPE': 'TEXT', 79 'OUTPUT_TYPE': 'AUDIO', 80 'AUDIO': 'WAVE_FILE', 81 'LOCALE': 'en_US', 82 }) 83 machine.succeed(f"curl 'localhost:${toString port}/process?{query}' -o ./audio.wav") 84 machine.copy_from_vm("./audio.wav") 85 ''; 86 } 87)