$template_name, ] ), fn() => \file_get_contents( \rosavox\helpers\string_\coin( '{{directory}}/templates/{{name}}.html.tpl', [ 'directory' => /*__DIR__*/'.', 'name' => $template_name, ] ) ) ), $arguments ); } /** */ function navigate(string $target) : void { \header('Location: ' . $target); } /** */ function generate_audio( string $input_value, string $output_path, ?array $options = null ) : void { $options = \array_merge( [ 'blocking' => false, ], ($options ?? []) ); $key = \hash('sha256', $input_value); $input_path = \rosavox\helpers\string_\coin( '/tmp/{{key}}.txt', [ 'key' => $key, ] ); \file_put_contents($input_path, $input_value); $command = \rosavox\helpers\string_\coin( 'scripts/generate-audio {{input_path}} {{output_path}}{{suffix}}', [ 'input_path' => $input_path, 'output_path' => $output_path, 'suffix' => ($options['blocking'] ? '' : ' > /dev/null 2>&1 &'), ] ); // \unlink($input_path); // \error_log(\sprintf("-- %s\n", $command)); \exec($command); } /** */ function translate(string $key, ?array $options = null) : string { $strings = \rosavox\helpers\cache\get( 'strings', fn () => \json_decode(\file_get_contents('strings.json'), true) ); $options = \array_merge( [ 'language' => 'de', ], ($options ?? []) ); return ($strings[$options['language']][$key] ?? \sprintf('{%s}', $key)); } ?>