-
-
Save hyuki/e14c4340b4695be26015b72a89c02271 to your computer and use it in GitHub Desktop.
talks.rb - Azure Speech CLIを使って話者二人の会話を作るRubyスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby | |
require 'wavefile' | |
include WaveFile | |
VOICE = [ | |
"ja-JP-NanamiNeural", | |
"ja-JP-KeitaNeural", | |
] | |
TSV = "_talks.tsv" | |
open(TSV, "w") do |f| | |
f.puts "voice\taudio.output\ttext" | |
DATA.each_with_index do |line, index| | |
f.puts "#{VOICE[index % 2]}\t#{sprintf("%03d", index)}.wav\t#{line}" | |
end | |
end | |
system("sudo docker run -it -v /YOUR/WORKING/DIR/:/data --rm msftspeech/spx synthesize --foreach in #{TSV}") | |
Writer.new("output.wav", Format.new(:mono, :pcm_16, 16000)) do |writer| | |
Dir.glob("00*.wav").sort.each do |filename| | |
Reader.new(filename).each_buffer do |buffer| | |
writer.write(buffer) | |
end | |
end | |
end | |
__END__ | |
これはファイルから読み込んでいます。 | |
TSVファイルを利用して複数のファイルを作っています。 | |
話者も切り換えられるといいですね。 | |
切り換えられるみたいですよ。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/hyuki/status/1445738596695044099