今回はTTSエンジンの各種情報を列挙するマクロを紹介します。
Microsoft Speech Platformがインストールされていない場合はSAPIからオブジェクトを取得します。
Option Explicit
Public Sub Sample()
Dim sv As Object
Dim st As Object
Set sv = CreateSpVoice
If sv Is Nothing Then Exit Sub
On Error Resume Next
For Each st In sv.GetVoices
Debug.Print "--------------------"
Debug.Print "ID:" & st.id
Debug.Print "Name:" & st.GetAttribute("Name")
Debug.Print "Language:" & st.GetAttribute("Language")
Debug.Print "Gender:" & st.GetAttribute("Gender")
Debug.Print "Age:" & st.GetAttribute("Age")
Debug.Print "Vendor:" & st.GetAttribute("Vendor")
Debug.Print "--------------------"
Next
On Error GoTo 0
Set sv = Nothing
End Sub
Private Function CreateSpVoice() As Object
Dim sv As Object
Set sv = Nothing '初期化
On Error Resume Next
Set sv = CreateObject("Speech.SpVoice")
If Err.Number <> 0 Then
Set sv = CreateObject("SAPI.SpVoice")
Err.Clear
End If
On Error GoTo 0
Set CreateSpVoice = sv
End Function















この記事へのコメントはありません。