Last active
March 12, 2019 11:59
-
-
Save ksasao/95f274935a627929a2c1 to your computer and use it in GitHub Desktop.
PowerPoint 2013 のノート部分をPepperさんに読み上げてもらう最小限のコード。C#のコードは Visual Studio 2013 のテンプレートから PowerPoint 2013 アドオン を選択して作成し、下記のコードに置き換える。Pythonのコードは Windows上に配置しPowerPointアドインから呼び出す。UTF-8 で保存すること。別途 Python NAOqi SDK をコミュニティサイトからダウンロードする。参考画像 https://twitter.com/ksasao/status/556364972574265346 License: WTFPL
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
# -*- coding: utf-8 -*- | |
import sys | |
from naoqi import ALProxy | |
data = sys.argv[1] | |
animSpeech = ALProxy('ALAnimatedSpeech', "(PepperのIPアドレス)", 9559) | |
p = unicode(data, 'shift-jis').encode('utf-8') | |
sentence = "\RSPD="+ str( 100 ) + "\ " | |
sentence += "\VCT="+ str( 120 ) + "\ " | |
sentence += str(p) | |
sentence += "\RST\ " | |
configuration ={"bodyLanguageMode":"contextual"} | |
animSpeech.post.say(str(sentence), configuration) |
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Xml.Linq; | |
using PowerPoint = Microsoft.Office.Interop.PowerPoint; | |
using Office = Microsoft.Office.Core; | |
namespace PowerPointAddIn1 | |
{ | |
public partial class ThisAddIn | |
{ | |
private void ThisAddIn_Startup(object sender, System.EventArgs e) | |
{ | |
} | |
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) | |
{ | |
} | |
#region VSTO で生成されたコード | |
/// <summary> | |
/// デザイナーのサポートに必要なメソッドです。 | |
/// このメソッドの内容をコード エディターで変更しないでください。 | |
/// </summary> | |
private void InternalStartup() | |
{ | |
this.Startup += new System.EventHandler(ThisAddIn_Startup); | |
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); | |
this.Application.SlideShowNextClick += Application_SlideShowNextClick; | |
} | |
#endregion | |
// スライドショーでページが切り替わった場合に発生するイベント | |
void Application_SlideShowNextClick(PowerPoint.SlideShowWindow Wn, PowerPoint.Effect nEffect) | |
{ | |
// PowerPointスライドの 「ノート」部分を取得する。 | |
// http://msdn.microsoft.com/ja-jp/library/office/ff744720(v=office.15).aspx | |
// 等を参照 | |
string note = Wn.View.Slide.NotesPage.Shapes.Placeholders[2].TextFrame.TextRange.Text; | |
if (note.Trim() != "") | |
{ | |
string scriptPath = @"(スクリプトのPath)\PepperTalkOnce.py"; | |
System.Diagnostics.ProcessStartInfo process = | |
new System.Diagnostics.ProcessStartInfo(); | |
process.FileName = "python.exe"; | |
process.Arguments = "\"" + scriptPath + "\" " + note; | |
process.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; | |
//アプリケーションを起動する | |
System.Diagnostics.Process.Start(process); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment