• joyofthink
  • Linkblog
  • Photoblog

Joy of Think


  • Home
  • About Blog A
  • About this system
  • Contact
  • Log in

Install Rubygem in Ubuntu 8.10

March 4th, 2010

In ubuntu 8.10, gem version is too low to install latest rails. And ubuntu forbid command gem update --system

To install latest gem in Ubuntu 8.10, please follow these instruction:

  1. Goto http://rubyforge.org/projects/rubygems/ to download latest rubygem-update-???.gem
  2. Run following commands:

    sudo gem install rubygem-update-3.??.gem
    sudo update_rubygems

Posted in Welcome | Send feedback »

Introduction to write C extension for Ruby

January 16th, 2010

Today, I am trying to use festival c/c++ api to say a word. After checking document, I decided to write an extension for ruby.
It is a simple task. All your need to do is:

Write a extension c file.

This file must define a function:
void Init_your_module_name()
It will be called on ruby loading it.
require "your_module_name"

In this function, generally, you must have following codes:


VALUE rb_mFestivalTTS;

rb_mFestivalTTS = rb_define_module( "FestivalTTS" ); //Define a module.
rb_define_module_function( rb_mFestivalTTS, "say", say, 1 ); //Define a function in module.

Write a extconf.rb

# extconf.rb
require 'mkmf'

dir_config('your_package_name')
create_makefile('your_package_name')

You can use find_library and find_header to add library and include path.

Run "make" command.


ruby extconf.rb
make

But it is a complex task too.

mkmf.rb doesn't support C

You must stick to C language.

You must be familiar with Ruby internal

All value passed bewteen extension and ruby inteperator is VALUE. It has a lot of api to manipuate VALUE. You must study <ruby.h>

Especially, you can use VALUE as a string by: StringValueCStr().

Posted in Welcome | Send feedback »

ruby脚本判断os

January 14th, 2010

ruby定义了一个预定义的常量 RUBY_PLATFORM 可以用来实现平台判断.
在ubuntu 9.10下是 i386-linux
在windows下是i386-mswin32

Posted in Welcome | Send feedback »

festivaltts4r分析

January 14th, 2010

festivaltts4r是ruby的一个gem,用来实现tts.分析它的代码,发现这是一个非常低效的实现,就是直接执行festival --tts的命令来发声.
festival本身提供festival-client模式和api模式,采用这两种应该可以提供更高效的实现.

Posted in Welcome | Send feedback »

Using TTS in Ubuntu

January 14th, 2010

Ubuntu uses festival as its TTS solution.

sudo aptitude install festival

But it has problem to work with PluseAudio and Bluetooth. For overcoming this problem, I found following wiki. Please notice following section "Configuration for ESD or PulseAudio"

  • Open the configuration file by typing gksudo gedit /etc/festival.scm or gedit ~/.festivalrc in a terminal.
  • Add the following lines at the end of the file:
    (Parameter.set 'Audio_Method 'esdaudio)
  • Save the file.

Posted in Welcome | Send feedback »

1 2 3 4 5 6 7 8 9 10 11 ... 13 >>
  • March 2010
    Sun Mon Tue Wed Thu Fri Sat
     << <   > >>
      1 2 3 4 5 6
    7 8 9 10 11 12 13
    14 15 16 17 18 19 20
    21 22 23 24 25 26 27
    28 29 30 31      
  • Joy of Think

    • Recently
    • Archives
    • Categories
    • Latest comments
  • Search

  • Categories

    • All
    • Background
    • Bookmark
    • English
    • Fun
      • In real life
        • Movies
        • Music
        • Sports
      • On the web
    • News
    • Programming
      • Android
      • C++
      • Linux
        • Toolchain
      • Perl
      • Web
        • Catalyst
        • HTML
        • Javascript
          • YUI
      • Windows Kernel
    • Toolkits
      • vim
    • Welcome
  • Blogroll

    • b2evolution
      • Blog news
      • Manual
      • Support
      • Web hosting
    • contributors
      • Daniel
      • Danny
      • Francois
      • Yabba
  • XML Feeds

    • RSS 2.0: Posts, Comments
    • Atom: Posts, Comments
    More on RSS
powered by b2evolution

©2010 by yangchen | Contact | Design by Michael | Credits: free blog | green hosting | François