Thursday, September 3, 2015

Adobe Reader: "Cannot find or create [font-name]"

The  "Cannot find or create [font-name]" problem comes up nearly every time I build a new Windows box then install Adobe Acrobat Reader or Pro.  This time it was on a Windows 10 x64 box.

The fix that worked for me was to delete Adobe's local cached files with:

rmdir "%userprofile%\AppData\Local\Adobe\Acrobat\" /s /q



Saturday, January 31, 2015

CentOS 7 PostgreSQL 9.2 install

Here's what I did to install PostgreSQL on a CentOS 7 box.  As root:

yum -y install postgresql postresql-server postgresql-contrib postgresql-libs

Optionally, install pgAdmin III with:
yum -y install pgadmin3

Configure initial database structure:
postgresql-setup initdb

Configure PostgreSQL to listen on all IPs by editing /var/lib/pgsql/data/postgresql.conf.  Change listen_addresses = '*'

Start the server:
systemctl start postgresql

Check that the service is listening:
netstat -antup | grep 5432

Modify /var/lib/pgsql/data/pg_hba.conf to allow md5

## IPv4 local connections:
host    all             all             127.0.0.1/32            md5 
# IPv6 local connections:
host    all             all             ::1/128                 md5 

As the user postgres reload configuration:
su - postgres
pg_ctl reload

As postgres, create a test database and an administrative user:
createdb test
psql test
CREATE USER root WITH SUPERUSER LOGIN PASSWORD 'password';
\q

As root, configure PostgreSQL to start with the system:
systemctl enable postgresql


.ssh permissions on a *nix box

Mostly to remind myself...set .ssh permissions on a *nix box.  From ~:

chmod 700 .ssh
chmod 644 .ssh/id_rsa.pub
chmod 600 .ssh/id_rsa

End result is:

  • .ssh directory is (drwx------)
  • public key (.pub file) is (-rw-r--r--)
  • private key (id_rsa) is (-rw-------)

That's better.


Friday, January 2, 2015

Build libsdl2-dev deb package for Raspbian on Raspberry Pi

Some projects I want to experiment with require Simple DirectMedia Layer (SDL) version 2 for Raspbian on a Raspberry Pi.  Unfortunately, the debian package for libsdl2-dev is not currently included in Raspian Repository.  Jan Zumwalt described how to build libsdl in his post titled "How To Install & Use SDL2 on Raspbian PI".  I prefer to install software via package managers when possible so I decided to make a .deb for libsdl2-dev.

Install devscripts
sudo apt-get install devscripts

Download libsdl 2.0.  I used SDL2-2.0.3.tar.gz.  Then follow the IntroDebianPackaging guide.

rename the SDL2-2.0.3.tar.gz to SDL2_2.0.3.tar.gz
extract the tar.gz
All the necessary files for building a .deb are already in the debian folder

Run debuild
debuild -uc -us

Install missing build dependencies
sudo apt-get dh-autoreconf libpulse-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev

Run debuild again
debuild -uc -us

Install packages
sudo dpkg -i libsdl2_2.0.3_armhf.deb
sudo dpkg -i libsdl2-dev_2.0.3_armhf.deb


Sunday, December 21, 2014

PowerShell Text-to-Speech (TTS).

Here is a PowerShell one liner for Text-to-Speech (TTS) using Microsoft's desktop oriented Speech API (SAPI).

(New-Object -ComObject Sapi.SpVoice).Speak("Hello There!")

It uses New-Object to create a Component Object Model (COM) instance of SAPI spVoice.

Actually, if you plan to use speech in script it will make more sense to keep the object around for reuse.

$synth = New-Object -ComObject Sapi.SpVoice
$synth.Speak("Hello Again!")

In the Windows jungle there is no escape from King-COM!


Oh...wait..You can also access SAPI via .NET instead of directly using COM.  You can make the SAPI  System.speech assembly accessible by using Add-Type.

Add-Type -AssemblyName System.speech
$synth = New-Object System.Speech.Synthesis.SpeechSynthesizer
$synth.Speak("Hello from dot net")

SAPI is fun to play with but it comes with a limited set of voices and speech recognizers.  If you want to experiment with other voices you'll need to purchase them or switch speech systems.  One option is the Microsoft Speech Platform which supports several additional voices.

Unfortunately, voices and speech recognizers are not compatible between the two Microsoft speech systems. They have slightly different designs reflecting their different use cases.  SAPI is designed for desktop platforms and single users.  The SAPI speech recognizers are tuneable to a specific user and they support recognition of arbitrary words with a diction engine.  A single  running instance of the SAPI speech system can be shared among many applications (i.e. the SAPI provider runs out-of-process).  The Speech Platform is server oriented.  It is in-process (AKA InProc) so each process that requires speech capabilities will have it's own instance of the Speech Platform speech system.  You could run multiple speech capable processes on a single server (e.g. concurrent voice recognition processes on several users voice mailboxes).

I'm assuming that you have already downloaded and installed the Microsoft Speech Platform SDK, runtime, language packs (speech recognizers and text-to-speech voices) you want to use.  Once again, use Add-Type to add the Speech Platform assembly and create Microsoft.Speech objects in a PowerShell environment.  The Speech Platform requires you to set the audio output destination so you can hear what is said.

Add-Type -Path "C:\Program Files\Microsoft SDKs\Speech\v11.0\Assembly\Microsoft.Speech.dll"
$ms_speak = New-Object Microsoft.Speech.Synthesis.SpeechSynthesizer
$ms_speak.setOutputToDefaultAudioDevice()
$ms_speak.Speak("Hello, again, and again!")

After creating the SpeechSynthesizer object You can record the speech to a file with:

$ms_speak.setOutputToWaveFile("hello.wav")
$ms_speak.Speak("Greetings")
$ms_speak.Dispose()

You must Dispose of the object to commit the speech audio data to the named file.

I recommend  reviewing the MSDN documentation for both speech systems. Also, check out the Out-Voice function and this blog post (both by Boe Prox) he describes how you can spelunk the two systems from PowerShell with Get-Member.  Finally, Language Packs provide SAPI text-to-speech voices and speech recognizers for a few non-English languages.
--
P.S. Technically you can use SAPI InProc or shared (out-of-process).
P.P.S. There really is no getting away from COM.  It's still one of the architectural pillars of Microsoft server and desktop products.



Sunday, November 16, 2014

PowerShell one liner to download a file from a URL

PowerShell 3 and 4 include the Invoke-WebRequest (wget) to download a file from a URL.

A PowerShell 4 one liner to download a file from a URL is:

Invoke-WebRequest url -OutFile filename

Replace url with a string that has the full URL for the file and replace filename with a string containing the local file name.  For example, to download get-pip.py I could do the following:

Invoke-WebRequest "https://raw.github.com/pypa/pip/master/contrib/get-pip.py" -OutFile "get-pip.py"

 In PowerShell 2 you can use the following one liner to achieve the same.

(New-Object System.Net.WebClient).DownloadFile(url,filename)

For example, to download get-pip.py I could do the following:

(New-Object System.Net.WebClient).DownloadFile("https://raw.github.com/pypa/pip/master/contrib/get-pip.py","get-pip.py")

Optionally, if you are running Windows 7 you could switch  to PowerShell 4 by installing Windows Management Framework 4.0.


Sunday, August 31, 2014

Install Kinect for Windows SDK v1.8

Here are the steps I completed to install the Kinect for Windows SDK version 1.8 on a Windows 8.1 x64 box with Visual Studio 2010 already installed.  These steps were adapted from the Kinect for Windows SDK 1.8 System Requirements page at MSDN.

1. Uninstall Microsoft Visual C++ 2010 x86 & x64 Redistributable.  KB2728613 provides the following:
MsiExec.exe /passive /X{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}

MsiExec.exe /passive /X{1D8E6291-B0D5-35EC-8441-6616F567A0F7}
2. Install the DirectX Software Development Kit. At the moment this seems to be the June 2010 version.

3. Update Microsoft Visual C++ 2010 x86 & x64 Redistributable.  I used Windows Update.


5. Install Games for Windows Marketplace Client.  See Stack Overflow "How to install the XNA Game Studio 4.0 in Windows 8?" for the reason why. Install Microsoft XNA Game Studio 4.0.  (It might be worth checking one of the versions at XNA Game Studio project on Codeplex.

6. Finally, Install KinectSDK v1.8 and Kinect for Windows Developer Toolkit v1.8.