質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

2158閲覧

PythonでSAPI5を使うときにSSMLを使う方法

tyobit

総合スコア17

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2018/08/03 06:22

現在、PythonでSAPI5を用いてテキスト読み上げを行うときにXMLタグを用いて局所的に音量や音程を変えようとしています。
それをSSMLタグを用いて行いたいのですがやり方がよくわかりませんのでアドバイスいただけたら助かります。

以下に、現在使っているXMLを用いたコードを添付しておきます。

Python

1 # -*- coding: utf-8; -*- 2#Python3.x 3 4 5from win32com.client import constants 6import win32com.client 7import sys 8 9#speech = win32com.client.Dispatch("Speech.SpVoice") 10speech = win32com.client.Dispatch("Sapi.SpVoice") 11SVSFlag = 11 # SVSFIsXML | SVSFlagsAsync | SVSFPurgeBeforeSpeak 12 13 14voiceInfo = speech.GetVoices() 15voices = 20*[''] 16for i in range(voiceInfo.Count): 17 voices[i] = voiceInfo.Item(i).GetAttribute("Name") 18 print ("(" + str(i) + ") " + voices[i]) 19 20while 1: 21 voiceNo = int(input('Voice 0 to ' + str(voiceInfo.Count-1)+ ' : ')) 22 print (voiceInfo.Count) 23 if 0 <= voiceNo and voiceNo < voiceInfo.Count: 24 print (voiceNo) 25 break 26 27 28while 1: 29 volume = int(input('Volume 0 to 100 : ')) 30 if 0 <= volume and volume<= 100: 31 print 32 break 33 34while 1: 35 rate = int(input('Rate -10 to 10 : ')) 36 if -10 <= rate and rate <= 10: 37 break 38 39while 1: 40 pitch = int(input('Pitch -10 to 10 : ')) 41 if -10 <= pitch and pitch <= 10: 42 break 43try: 44 speech.Voice = voiceInfo.Item(voiceNo) 45except: 46 print ("fail to set property (by assign)") 47 try: 48 speech.SetVoice(voiceInfo.Item(voiceNo)) 49 except: 50 print ("fail to set property (by SetXXX)") 51speech.Volume = volume 52speech.Rate = rate 53 54while 1: 55 str = input("Input : ") 56 if len(str)==0: 57 sys.exit() 58 print (str) 59 str = str.replace("<","&lt;") 60 str = str.replace("[","<rate absspeed=\"4\">") 61 str = str.replace("]","</rate>") 62 str = "<pitch absmiddle=\"%s\">%s</pitch>"%(pitch,str) 63 speech.Speak(str,SVSFlag) 64

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問