Skip to content

Posts

VOICEVOX

Docker Desktopもインストールしたので、最近話題のVOICEVOX | 無料で使える中品質なテキスト読み上げソフトウェアを試してみた。

$ docker run -it --rm -p 50021:50021 hiroshiba/voicevox_engine:cpu-ubuntu20.04-latest

最初、GoとDockerでつくる音声合成CLIのページを参考にしてバージョン指定してたけど、latestにしたら使えるキャラクターが増えた。つい最近追加されたらしい。

上記ページを参考に、スクリプト作って、生成されたwavファイルをメディアプレーヤーで再生。

#!/bin/sh
TXT=`cat hello.txt`
curl -s -XPOST -G "http://localhost:50021/audio_query?speaker="$1 --data-urlencode text=$TXT \
| curl -s -XPOST "http://localhost:50021/synthesis?speaker="$1 \
-H 'accept: audio/wav' -H 'Content-Type: application/json' -d @- \
> hello.wav

テキストファイル監視して保存したら再生されるみたいな仕組み作れそうだけど、時間あるときにやるネタにしておこう。。

Read more

Rancher Desktop

Inspironクリーンインストールした後、Dockerのセットアップしてなかったの忘れていて、せっかくなのでRancher Desktopを試してみることにした。

公式ページからWindows用のインストーラーをダウンロードして実行。

起動時に聞かれるContainer Runtimedockerdを選択した。

PowerShell でdockerコマンド使えるようにはなったけど、WSL2とかVS CodeからだとPermission deniedでダメだ。。

Read more

バグ発見

ループと休符の組み合わせで、休符が消える現象が起きてる気がする。

後から実装したところはちょっと入り組んでしまっているね。。

Rust学習

The Rust Programming Language 日本語版 - The Rust Programming Language 日本語版、途中飛ばして12章やってたけれど、やっぱり最初からやったほうが良い気がしてきた。

そして、最初のページに

すべてのプロジェクトの Cargo.toml に edition=“2018” とあることを前提にしています。 との注意書きがあるのに今更ながら気づいた。

昨日エラーが出ると言っていたのは、edition = "2021"だったので、試しに2018にしてみたらエラーではなく警告に変わった。

Read more

dynとは?

リファクタリングしてモジュール性とエラー処理を向上させる - The Rust Programming Language 日本語版 を写経していて、コンパイルエラーに遭遇した。

$ cargo run
   Compiling mdmml_rust v0.1.0 (mdmml_rust)
error[E0782]: trait objects must include the `dyn` keyword
  --> src/main.rs:21:41
   |
21 | fn run(config: Config)-> Result<(), Box<Error>> {
   |                                         ^^^^^
   |
help: add `dyn` keyword before this trait
   |
21 - fn run(config: Config)-> Result<(), Box<Error>> {
21 + fn run(config: Config)-> Result<(), Box<dyn Error>> {
   | 

For more information about this error, try `rustc --explain E0782`.
error: could not compile `mdmml_rust` due to previous error

修正方法も提示してくれて親切。

で、このdynとは何なのか。書かれているようにrustc --explain E0782を実行すると、以下の出力となった。

Read more

VS CodeのRust用設定

コードフォーマッターが欲しいと思って、プラグインを入れたけれど動かない。

Couldn't start client Rust Language Server
---
Rustup not available. Install from https://www.rustup.rs/

どうやらツールが足りないようなので、追加でインストールした。

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
$ source $HOME/.cargo/env
$ rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.59.0 (9d1b2106e 2022-02-23)`

それでもエラーが解消しなかったので、OSごと再起動したら反映された。

Read more

Rust再入門

以前RustでHello Worldするのはやってたので、再入門。

The Rust Programming Language 日本語版 - The Rust Programming Language 日本語版を見ながら。

今回はcargoを使ってビルドするようにしてみた。

マニュアルだとcargo newで作成しているが、先にGitHubでリポジトリを作ってしまっていたので、cargo initを使っている。

$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
$ source $HOME/.cargo/env
$ rustc --version
rustc 1.58.1 (db9d1b20b 2022-01-20)
$ cargo --version
cargo 1.58.0 (f01b232bc 2022-01-19)
$ cargo init
$ cargo build
   Compiling mdmml_rust v0.1.0 (/home/umemak/workspace/mdmml_rust)
    Finished dev [unoptimized + debuginfo] target(s) in 0.36s
$ ./target/debug/mdmml_rust 
Hello, world!
$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.00s
     Running `target/debug/mdmml_rust`
Hello, world!

別言語で実装

大体やりたいことはやった感が出てきたので、go以外の言語で実装してみたいと思う。

やってることはテキスト変換なので、未知の言語の練習にもちょうどよいかと。

ということでRustでやってみる。

前二日間更新がなかったのは、ワクチン副作用でダウンしていたため。