Asterisk - Voicemail with Speech Recognition using Google API

Asterisk

In a previous article I published a solution to convert Asterisk voicemail attachments from WAV to MP3 on the fly. This is done by catching the mails sent by Asterisk just before they are passed to sendmail.

I recently got the idea from Daniel Dainty to add Voice Recognition feature at the same time as mp3 encoding.

After testing different voice recognition engines, I realized that the Google Speech Recognition API is by far superior to any other solution available under Linux (Sphinx, ...).

This article will explain an approach to add voice recognition to Asterisk voicemail using the services of Google Speech Recognition API.

The principle is very simple. After doing the voicemail mp3 conversion, the script :

  1. does some pre-processing clean-up on the file,
  2. converts it to an acceptable format (flac),
  3. sends it to Google speech recognition engine,
  4. gets back the text version
  5. adds it at the end of the mail body.

This procedure has been done on a Debian Squeeze server. It should be fully compatible with an Ubuntu server. You will then just need to add sudo to the commands needing root privilege.

Read more: Asterisk - Voicemail with Speech Recognition using Google API

Ubuntu 12.04 - Configuration of Tata Photon +

Tata Photon Plus

This article will explain how to fully setup and configure a CDMA USB key Huwei EC156 provided with a Tata Photon + subscription on a Ubuntu 12.04 laptop.

Just imagine : You are staying or travelling in India, you are checking your mails or surfing the web while in a taxi, in the train or waiting in an airport ... That is nowadays quite easy, you just need a nation wide wireless internet access.

Tata Photon + is there to suit your needs. For a reasonible amount (around 1500 INR, equivalent to 20 €) you can get a Huwei EC156 USB key and a 3 Gb limit, valid for one month.

The Huwei EC156 chipset embedded with the key is recognised by Ubuntu 12.04 but you need to declare a specific APN.

This article will explain the very simple steps to get a fully working CDMA connexion with a Huwei EC156 Tata Photon + USB key under Ubuntu 12.04 LTS.

Read more: Ubuntu 12.04 - Configuration of Tata Photon +

Ubuntu 12.04 - Installation on Acer Aspire One 722 (AO722)

Acer Aspire One 722

This article explains the specific steps needed to fully configure an Acer Aspire One 722 to run under Ubuntu Precise 12.04.

Even if Acer AO722 support is much better under Ubuntu 12.04 than under Ubuntu 11.04, there are still some tuning to be done before getting a perfectly running laptop.

It will allow you to specifically deal with :

  • Random system freeze
  • Problems with microphone configuration

A standard installation of Ubuntu Precise 12.04 AMD64 desktop edition is a pre-requisite for this procedure.

Read more: Ubuntu 12.04 - Installation on Acer Aspire One 722 (AO722)

Ubuntu 12.04 - Installation on Asus F301A

dropcap-ubuntu-asus-f301a

This article will explain how to fully configure an Asus F301A laptop under Ubuntu 12.04 LTS with Gnome Shell or Gnome Classic interface.

This laptop is very versatile, offering a 13'' screen with a performant dual core Intel CPU. It is embedded with Windows 8, which can be easily replaced by an Ubuntu Linux distribution.

The following article will allow you to fully configure your Ubuntu Linux, allowing to use :

  • Elantech touchpad
  • Ralink RT5390 wifi adapter
  • brightness function keys

It has been tested on an Asus F301A-RX172H.

All the following tweaks have to be applied on a basic Ubuntu 12.04 LTS 64bits installation.

If you are ready to follow this procedure, you can safely ask for your Windows licence refund  :-)

Read more: Ubuntu 12.04 - Installation on Asus F301A

Ubuntu - Remote assistance, the very simple way with Gitso

Ubuntu

If you are part of the Ubuntu herd, you may have already converted some friends or relatives to the joy of linux freedom.

Then comes the time of remote assistance, where you have to understand over the phone what is happening on a remote screen with the person seeking for help giving you these very detailled explainations "It is not working any more. Yesterday it was ok. What to do ?".

A remote desktop like VNC can be a very effective answer to that need, but it has 2 main drawbacks :

  • it is complicated to configure and setup for a non technician
  • is does not go thru NAT firewall that easily, needing some port forwarding

ubuntu-gitso-logoA very simple tool called Gitso can be a very good answer to these 2 problems, as it is a multi-platform reverse VNC remote desktop and it is extremely easy to setup.

As it is a reverse VNC server, the person who needs support (who is not a computer person and most of the time doesn't even know what a firewall is) will initiate the connexion. So the firewall configuration will be fully on your side.

This article explains how to install Gitso on both computers so that starting a remote assistance between 2 Ubuntu desktop becomes as easy as possible. It has been tested under Ubuntu 11.04 & 12.04, but it should work with and type of Debian or Ubuntu flavoured distribution.

Read more: Ubuntu - Remote assistance, the very simple way with Gitso

Ubuntu - Tweaks for SSD drive

dropcap-ubuntu-ssd

Nowadays, SSD disks are more and more common, especially for laptops, as they are by nature shock proof.

Even if they don't offer the same price per Gb than standard hard disk, they provide a fantastic performance boost and are more and more affordable.

But, even if it gives a huge boost, a SSD disk is not behaving like a normal hard disk with rotating platters. Their main characteristics are :

  • their very fast read and write speed
  • their neutrality to random access
  • their limited write cycles

This article explains how to tweak a Ubuntu computer to take the full benefit of a SSD drive and to preserve it at the maximum against unneeded write accesses.

This has been tested on Ubuntu Precise 12.04 AMD64, but it should be applicable to any debian derived flavour and even to any Linux distribution for most of it.

Read more: Ubuntu - Tweaks for SSD drive

Ubuntu - Automount Nexus 7 in MTP mode

dropcap-ubuntu-android

Latest Android devices, like Nexus 7, are using 2 different USB connexion modes : PTP and MTP.

With PTP mode, the tablet is seen as a digital camera. This is working Out Of The Box under Ubuntu 12.04. But, you can only access DCIM directory of your device.

With MTP mode, the tablet is seen as a multimedia device where you can access the complete exported filesystem. But it doesn't work Out Of The Box under Ubuntu 12.04. It needs some setup and configuration to work.

Even if you can access easily a MTP device thru a program called gmtp, it is not as convenient as a conventional USB mass storage, accessible directly from Nautilus.

This guide explains how to configure your Ubuntu computer to directly access your Nexus 7 exported filesystem in MTP mode as soon as you plug it to a USB port.

Thanks to some udev rules, your Nexus 7 will automatically mount when device is plugged in & unmount when device is unplugged.

This guide has been done for Google Nexus 7, but it should work with any other MTP device (Android phone or tablet, MP4 player, ...) if you adapt the Udev rules according to your device.
I've got some feedback that it has already been adapted succesfully to Samsung Galaxy S2, Galaxy S3, Motorola Atrix HD & Google Nexus 4.

It has been done under Ubuntu 12.04, but has also been tested succesfully under Ubuntu 12.10.

Read more: Ubuntu - Automount Nexus 7 in MTP mode

Ubuntu - Imposition or how to print a book from your documents

Ubuntu

ubuntu-imposition-bookIn daily office life, who has not thought while printing a document :

It's a waste to print that document on A4 pages.
It would have been so handy to get it in a small A5 booklet.

Imposition is the clue !

Imposition is the process of arranging pages on printer's sheet, in order to obtain faster printing, simplified binding and reduced paper waste.

This guide will explain how to achieve that simple process of converting a plain document in portrait mode into a small A5 booklet printed on recto-verso A4 pages.

As an input, it takes a an LibreOffice, Ms-Office or PDF document and generates a PDF document ready for printing.

By default you will generate a document ready for printing on A4 pages, but some other formats like A3, A5, Letter, ... are also available (thanks to Robin idea).

It has been tested on Ubuntu 12.04 LTS, Ubuntu Gnome and Lubuntu 14.04 LTS, but it should work on any Linux flavor as long as you get pdfinfo, pdfbook and unoconv utilities.

If you don't need any technical explanation and you just want to be able to generate a PDF booklet straight from Nautilus file manager, you can jump to Complete installation procedure. It will provide a complete and simple installation script.

Some Explainations

Before going to the scripting part, lets understand the process.

Booklet Imposition main goal is simplicity. You should get :

  • no cutting
  • pages folded in half lengthwise
  • pages stapled centerline

On every recto-verso A4 pages you will print 4 pages of the original document :

  • The first and last pages are printed on one side of a standard A4 page
  • The second and penultimate page on the other side of that same A4 page
  • The page should be printed recto-verso on the long-edge

You have to repeat that first/last & second/penultimate relationship going thru the document, until you reach the middle of the document.

ubuntu-imposition-process

You can now simply fold in half lengthwise the printed pages and staple the binding line.

The result is a A5 booklet printed on A4 pages.

Install Packages

The booklet generation script will need four specific tools :

  • pdfinfo : to get number of pages from original document
  • pdfbook : to do the imposition job
  • mimetype : to determine the type of input document
  • unoconv : to convert an office document to a PDF file

Under Ubuntu, these tools are provided by the following packages (valid for Precise 12.04 and Trusty 14.04) :

Terminal
# sudo apt-get install poppler-utils texlive-extra-utils mimetype unoconv

Imposition Script

The complete imposition job is done by a shell script.

This script takes the original document as a parameter. It adds blank pages at the end of the booklet if needed.

If no parameter is given, the scripts asks to select an input document.

Booklet is generated side to the original document, having the same name with -book appended at the end.

/usr/local/bin/generate-booklet
#!/bin/bash
# ---------------------------------------------------------
# Imposition of a document to generate a PDF booklet
# target format is selectable (A5, A4, ...) and default format is A4
#
# Setup procedure : http://bernaerts.dyndns.org/linux/74-ubuntu/248-ubuntu-imposition-print-book
#
# Depends on packages : poppler-utils, texlive-extra-utils, unoconv and mimetype
#
# Parameter :
#   $1 - full path of original document
#
# Version history :
#   26/09/2012, V1.0 - Creation by N. Bernaerts
#   05/05/2014, V2.0 - Add target format selection (thanks to Robin idea)
#   16/12/2014, V2.1 - Add file selection dialog
#   10/05/2015, V2.2 - Check tools availability
#   03/11/2015, V3.0 - Add support for LibreOffice & Ms-Office documents
#   18/10/2017, V3.1 - Correct critical bug (thanks to Igor Kushnir)
# ---------------------------------------------------------

# check mimetype, pdfinfo, pdfbook and unoconv
command -v mimetype >/dev/null 2>&1 || { zenity --error --text="Please install mimetype"; exit 1; }
command -v pdfinfo >/dev/null 2>&1 || { zenity --error --text="Please install pdfinfo [poppler-utils package]"; exit 1; }
command -v pdfbook >/dev/null 2>&1 || { zenity --error --text="Please install pdfbook [texlive-extra-utils package]"; exit 1; }
command -v unoconv >/dev/null 2>&1 || { zenity --error --text="Please install unoconv"; exit 1; }

# check if parameter is given, otherwise open dialog box selection
[ "$1" != "" ] && FILE_ORIGINAL="$1" || FILE_ORIGINAL=$(zenity --file-selection --title="Select document to convert to booklet")

# if no document selected, exit
[ ! -f "${FILE_ORIGINAL}" ] && exit 1

# booklet name will be originalname-book.pdf
FILE_BOOKLET="$(echo "${FILE_ORIGINAL}" | sed 's/\(.*\)\..*/\1/')-book.pdf"

# get the file mime type (application/msword, ...)
TYPE=""
MIMETYPE=$(mimetype -b "${FILE_ORIGINAL}")

# check if file is a libreoffice file (.odt, .ods, ...)
CHECK=$(echo "${MIMETYPE}" | grep ".opendocument.")
[ "${CHECK}" != "" ] && TYPE="libreoffice"

# check if file is a microsoft file 2007+ file (.docx, .xlsx, .pptx, ...)
CHECK=$(echo "${MIMETYPE}" | grep "vnd.openxmlformats-officedocument.")
[ "${CHECK}" != "" ] && TYPE="ms-office"

# if type is not found, check specific document types
[ "${TYPE}" = "" ] && case ${MIMETYPE} in 
  # ms-office document (.doc, .xls, .ppt, ...)
  "application/msword" | "application/vnd.ms-word" | "application/vnd.ms-powerpoint" )
    TYPE="ms-office"
    ;;

  # PDF document (.pdf)
  "application/pdf" | "application/x-pdf" | "application/x-bzpdf" | "application/x-gzpdf" )
    TYPE="pdf"
    ;;

  # plain text file (.txt)
  "text/plain" | "application/x-shellscript" )
    TYPE="text"
    ;;

  # other mimetype
  * )
    ;;
esac

# if document type is not a candidate one, exit
[ "${TYPE}" = "" ] && { zenity --error --text="Document format is not compatible (pdf, libreoffice or ms-office)"; exit 1; }

# select target format
ARR_FORMAT=('false' 'A2' 'false' 'A3' 'true' 'A4' 'false' 'A5' 'false' 'Letter' 'false' 'Executive' 'false' 'Legal')
TITLE=$(basename "${FILE_ORIGINAL}")
TEXT="Booklet will be generated from this document.\nPlease select target format.\n"
FORMAT=$(zenity --list --radiolist --width 350 --height 380 --title "${TITLE}" --text "${TEXT}" --column="Choice" --column="Format" ${ARR_FORMAT[@]})

# if no format selected, exit
[ "${FORMAT}" = "" ] && exit 1

# --------------------
#  booklet conversion 
# --------------------
(
# temporary file
FILE_TMP=$(mktemp -t XXXXXXXX.pdf) && rm "${FILE_TMP}"
  
# set target format as expected by pdfbook
OPTION="--${FORMAT,,}paper"

# if file is not PDF, convert file to pdf, else use original
echo "# Conversion of original document to PDF format"
[ "${TYPE}" != "pdf" ] && unoconv -f pdf -o "${FILE_TMP}" "${FILE_ORIGINAL}"

# set conversion source as temporary PDF or original PDF
[ -f "${FILE_TMP}" ] && FILE_SOURCE="${FILE_TMP}" || FILE_SOURCE="${FILE_ORIGINAL}"
  
# calculate number of pages of original PDF 
# and determine if blank pages to be added at the end to get multiple of 4
echo "# Calculate number of booklet pages"
NUMPAGES=$(pdfinfo "${FILE_SOURCE}" | grep Pages | sed 's/^Pages:[ ]*\([0-9]*\).*$/\1/g')
DIVPAGES=$(expr ${NUMPAGES} % 4)
[ "${DIVPAGES}" -gt "0" ] && NUMPAGES=$(expr ${NUMPAGES} + 4 - ${DIVPAGES})

# generate document with proper page number (multiple of 4)
echo "# Generation of PDF booklet"
pdfbook ${OPTION} --signature ${NUMPAGES} --booklet true --landscape "${FILE_SOURCE}" -o "${FILE_BOOKLET}"

# remove temporary PDF file
rm -f "${FILE_TMP}"
) | zenity --width=500 --height=25 --progress --pulsate --auto-close --title "${FORMAT} booklet generation"

You can use following commands to install the script and declare it into your utilities main menu.

Terminal
# sudo wget --header='Accept-Encoding:none' -O /usr/local/bin/generate-booklet https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/pdf/generate-booklet
# sudo chmod +x /usr/local/bin/generate-booklet
# sudo wget --header='Accept-Encoding:none' -O /usr/share/applications/generate-booklet.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/pdf/generate-booklet.desktop
# sudo chmod +x /usr/share/applications/generate-booklet.desktop

Access from Nautilus Menu

If you want your imposition script to be accessible straight from a right click menu on a LibreOffice, Ms-Office or PDF file in Nautilus, this can be done quite easily with Nautilus Actions.

If not already done, install Nautilus Action package and allow context menu icons :

Terminal
# sudo apt-get install nautilus-actions
# gsettings set org.gnome.desktop.interface menus-have-icons true

You are now ready to declare a new Nautilus action menu.

This action is declared by creating a specific .desktop file under ~/.local/share/file-manager/actions directory (which may not exist).

Action file declares to Nautilus the action to be launched according to some specific mimetypes.

~/.local/share/file-manager/actions/generate-booklet-action.desktop
[Desktop Entry]
Type=Action
Icon=emblem-documents
Name[C]=Generate Booklet
Name[en]=Generate Booklet
Name[en_US]=Generate Booklet
Name[fr_FR]=Générer un livret
Tooltip[C]=Tool to generate a PDF booklet
Tooltip[en]=Tool to generate a PDF booklet
Tooltip[en_US]=Tool to generate a PDF booklet
Tooltip[fr_FR]=Outil de génération d'un livret au format PDF
Profiles=generate_booklet;

[X-Action-Profile generate_booklet]
Exec=generate-booklet %f
MimeTypes=application/pdf;application/x-pdf;application/x-bzpdf;application/x-gzpdf;application/msword;application/vnd.ms-word;application/vnd.oasis.opendocument.text;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.oasis.opendocument.spreadsheet;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.openxmlformats-officedocument.presentationml.slideshow;text/plain;
Name[en_US]=Default profile
Name[en]=Default profile
Name[C]=Default profile

Following command creates action directory if it doesn't exist and declares Nautilus action :

Terminal
# mkdir --parents $HOME/.local/share/file-manager/actions
# wget --header='Accept-Encoding:none' -O $HOME/.local/share/file-manager/actions/generate-booklet-action.desktop https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/pdf/generate-booklet-action.desktop

All the needed steps are done to get a new  Generate booklet menu entry for PDF documents.

Complete installation procedure

If you want to install all needed tools and scripts in one go, you can run an all-in-one installation script available from my Github repository.

This script has been written and tested on Ubuntu 14.04 LTS. It will handle whatever installation and configuration described earlier in this article.

Terminal
# wget --header='Accept-Encoding:none' https://raw.githubusercontent.com/NicolasBernaerts/ubuntu-scripts/master/pdf/generate-booklet-install.sh
# chmod +x generate-booklet-install.sh
# ./generate-booklet-install.sh

Generate your PDF booklets

ubuntu-imposition-nautilus-menuAfter next login you should get a new  Generate booklet menu entry for PDF documents.

Everytime you select this menu on a PDF document, a A5 booklet is generated side to the original document.

You can now print it on any recto-verso printer in portrait mode, you will get your A5 booklet.

In case you detect any bug or if you have some update ideas which can benefit everybody, don't hesitate to contact me by email or to fork it on GitHub.

 

Hope it helps.

Ubuntu 12.04 - Install DLink DWA-160 B2 wifi adapter

dropcap-ubuntu-wifi

DLink DWA-160 USB key is a low price dual-band 2.4 and 5 GHz wifi adapter.

Latest hardware revision DLink DWA-160 rev. B2 is introducing a new RT5572 chipset as a replacement with RT7820.

The result is that, as most of the time with latest wifi adapters, this new harware revision is not recognised Out Of The Box under Ubuntu Precise 12.04.

The generic rt2800usb module is not able to handle the new chipset RT5572 embedded with the DWA-160 rev. B2.

dlink-dwa160-key

But, thanks to Ralink, the source drivers are publicly available.

So, with little effort, you will be able to get a working DWA-160 rev. B2 USB key under Ubuntu 12.04. This article explains all the steps needed to achieve this goal.

It will also explain how to configure DKMS so that your driver will be automatically built and installed during every kernel update.

It has been tested under Ubuntu 64bits Precise 12.04 with kernel 3.2.0-24 and 3.2.0-30. But it should work on the 32bits version.

Read more: Ubuntu 12.04 - Install DLink DWA-160 B2 wifi adapter

Ubuntu 12.04 - Rhythmbox and Totem as UPnP/DLNA clients

dropcap-ubuntu

Nowadays, uPnP/DLNA home servers are becoming very popular. These servers now come embedded with Windows clients, with network appliances like NAS, ... So you can today easily centralize and serve all your audio/video files.

But, on the other end, under Ubuntu Precise, it is still no so easy to get a media player (renderer) compatible with uPnP/DLNA servers.

upnp-dlna-symbol

Two very common media players, Rhythmbox (audio) and Totem (audio & video), provide some uPnP/DLNA playback support in their latest version, with the help of a new Gnome projet named Grilo.

But unluckily, this uPnP/DLNA support has not been packaged under Ubuntu Precise.

This article explains how to enable uPnP/DLNA playback on Rhythmbox and Totem (also known as Movie Player) under Ubuntu Precise 12.04.

The following configurations have been tested with TwonkyMedia 7 as a uPnp/DLNA server running on a NAS device.

Read more: Ubuntu 12.04 - Rhythmbox and Totem as UPnP/DLNA clients

Ubuntu 12.04 - EEE 701 with Gnome Shell 3.4

dropcap-eee701-ubuntu

EEE 701 was the first netbook widely available. It came to the market about 5 years back, which is pre-historical time in the computer world !

This little netbook main characteristics are :

  • 900 MHz Atom processor
  • 512 Mb RAM
  • 4 Gb SSD
  • 800×480 screen

It was shipped with a specific Linux distribution called Xandros, which is not maintained anymore.

Even if this netbook is little bit outdated, it deserves a second life !

This article will explain how to install the latest Ubuntu Precise 12.04 with latest Gnome Shell 3.4 on EEE 701, relying only on the main 4 Gb SSD. No extra memory card will be needed.

At the end of the installation process, you will be left with approximately 1 Gb of free space on the SSD.

The only extension advisable is to install 1 Gb RAM (or even better 2 Gb). On such a low powered processor, this will give a real boost to Ubuntu and Gnome Shell.

As a result, you will have a brand new EEE 701, perfect for any Web activity, Youtube, Skype, SD movies playback, …

Read more: Ubuntu 12.04 - EEE 701 with Gnome Shell 3.4

Page 6 of 9