0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

音声ツール作成 

Posted at

● [inputText.txt]は読み取りファイル。

音声ツール-wav.vbs

Option Explicit

if False then ' Windowsの音声合成エンジン
  'Microsoft Haruka - Japanese (Japan)
  'Microsoft Ichiro - Japanese (Japan)
  'Microsoft Sayaka - Japanese (Japan)
  'Microsoft Ayumi - Japanese (Japan)
end if

'::::::::::::::::::::::::::::::::::
' 必要に応じて、音声合成エンジンを設定
'::::::::::::::::::::::::::::::::::

Const target = "Microsoft Ayumi"
Const speed = 1 '--話すスピード

Dim fso
Dim sapi
Dim cat
Dim token
Dim fs
Dim oldv
Dim inputFile
Dim lineStr

Set fso = WScript.CreateObject("Scripting.FileSystemObject")

' 読み込みファイルの指定 (相対パスなのでこのスクリプトと同じフォルダに置いておくこと)
Set inputFile = fso.OpenTextFile("inputText.txt", 1, False, 0)
lineStr = inputFile.ReadAll

Set sapi = CreateObject("SAPI.SpVoice")
Set cat  = CreateObject("SAPI.SpObjectTokenCategory")
cat.SetID "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Speech_OneCore\Voices", False
For Each token In cat.EnumerateTokens
    If token.GetAttribute("Name") = target Then
        Set fs = CreateObject("SAPI.SpFileStream")
        fs.Open target & ".wav", 3
        Set sapi.AudioOutputStream = fs
        Set oldv = sapi.Voice
        Set sapi.Voice = token
        sapi.Rate = speed '--話すスピード
        ' sapi.volume = 100   '--声のボリューム
        sapi.Speak lineStr
        Set sapi.Voice = oldv
        fs.Close()
        Exit For
    End If
Next

' オブジェクトを廃棄します。
Set fso = Nothing
Set sapi = Nothing
Set cat = Nothing
Set fs = Nothing
Set oldv = Nothing
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?