Speak with given voice with Active TTS

You may want to speak with a special voice when using ActiveTTS. It is easy to do this with any script languages. Here is an example in perl:

 The script first lists the voices installed on the machine. Then you can set the voice index to be used with speak or speakfile by setting the property VoiceIdx.

use Win32::OLE;
$tts = Win32::OLE->new(‘TTSObj.TextToSpeech.1′) or die “oopsn”;

$n = $tts->get_VoiceCount();
for($i = 0; $i < $n; $i++)
{
 $tts->{VoiceIdx} = $i;
 print “VoiceIdx:”.$i.” Name:”.$tts->{VoiceName}.”n”;
}

#Set to the voice you wish
$tts->{VoiceIdx} = 1;
$tts->Speak(“Hello world”, 0);

$tts->SpeakToFile(“Hello world”, “1.mp3″, 0);
 

Handle ActiveX event in VBScript

The shell VBScript can handle ActiveX event as well. The following is an example on how to handle the events from our Active TTS  component.

 Save it and click to run on your desktop after installing our component.

 

Dim tts
Set tts = WScript.CreateObject(“TTSObj.TextToSpeech.1″, “tts_”)
tts.Speak “Hello world”, 0
sub tts_OnTTSStart
msgBox “start”
end sub

sub tts_OnTTSEnd
msgBox “end”
end sub

Check snap errors with htmlsnapshot

htmlsnapshot supports reporting error code for SnapUrl function. This can help you decide the problem of failing to snap certain pages.

 It works like this:

snap.SnapUrl(…..) 

 iErrorCode=snap.GetErrorCode()

The error code is an interger value which has following values:

0: The normal state.

1: The snapshot is successfully taken.

-1: Fail to take the snapshot of the page, check if your html image is too big to be fit into memory,

-2: Fail to save to file, check if you can write to the output image path

-3: Fail to open the URL. check network please

-4: Time is out before taking a snapshot, use a larger time out value or call SetForceSnap before snapping.

 

 

 

Save html to gif

Htmlsnapshot supports converting html to gif. And it supports creating transparent GIF as well.

The SetGIFOption can be used to enable or disable transparent Gif

Dim snap
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetTimeOut CLng(200000)

‘disable transparency gif
snap.SetGIFOption FALSE, &HFFFFFFFF
snap.SnapUrl “http://www.google.com/“, “0.gif”

‘enable transparency gif
snap.SetGIFOption TRUE, &HFFFFFFFF
snap.SnapUrl “http://www.google.com/“, “1.gif”

 

 

Create high quality image from html

htmlsnapshot generates the image at the screen DPI by default. To get a higher resolution image, there are two methods.

1. Use setzoom and setDPI method.  The following code zooms the image 3 times and set DPI as 300, 300

  Dim snap
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetTimeOut CLng(200000)

snap.SetDPI 300, 300
snap.SetZoom 3.0
snap.SnapUrl “d:temprptfile_200608140039.html”, “zoom.tif”

Set snap = Nothing

2.  generate a metafile first and convert it into raster image

 ’Declare object
Dim snap
Set snap = CreateObject(“HTMLSNAP2.HtmlSnap.1″)
snap.SetTimeOut CLng(200000)

snap.SnapUrl “file://d:temprptfile_200608140039.html“, “2.emf”

snap.SetDPI 300, 300

‘convert emf to tif, keep aspect ratio
snap.ConvertEMFToImage “2.emf”, “1.tif”, 6000, 6000, 1

Set snap = Nothing

 

Convert VML To image

VML is a kind of vector based graphic format.

html snapshot can convert VML to image like jpg, tiff etc. 

In Win2003, there is an “IE enhanced security” component which may restrict some behaviour of rending vml to image.  

So to make  vml to image work correctly, it is safer to remove the security component from Windows.  You can do this from the “Add/Remove software” control panel.