Testing PocketSphinx server - ruby

I'm interested in setting up a web based speech recognition service for testing purposes. I did some research and found Ruby PocketSphinx Server. They claim to accept input as an audio file and return a JSON file with the text from the audio input. This is exactly what I need.
The problem is I'm new to Ruby and Sphinx/PocketSphinx. Even though I followed the documentation to setup the environment, I'm still completely lost. I got as far as running this command unicorn -c unicorn.conf.rb config.ru but got this error:
/usr/lib/ruby/vendor_ruby/unicorn/configurator.rb:74:in `read': No
such file or directory - unicorn.conf.rb (Errno::ENOENT) from
/usr/lib/ruby/vendor_ruby/unicorn/configurator.rb:74:in `reload' from
/usr/lib/ruby/vendor_ruby/unicorn/configurator.rb:67:in `initialize'
from /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:104:in `new'
from /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:104:in
`initialize' from /usr/bin/unicorn:121:in `new' from
/usr/bin/unicorn:121:in `<main>'

In the root directory of the ruby-pocketsphinx-server folder there should be a file called unicorn.conf.rb.
You should be running the unicorn -c unicorn.conf.rb config.ru command in the root directory.

Related

How to rectify oci8.c error when executing a rest ruby script on DB application?

I'm executing ruby scripts for a REST based application which uses oic8 gems from ruby. While executing I end up with following error
I'm executing in linux box
OCIError:
ORA-12705: Cannot access NLS data files or invalid environment specified
# oci8.c:694:in oci8lib_210.so
# /usr/local/rvm/gems/ruby-2.1.10/gems/ruby-oci8-2.2.2/lib/oci8/oci8.rb:147:in `initialize'
# ./lib/common/oracle_connection.rb:9:in `new'
# ./lib/common/oracle_connection.rb:9:in `initialize'
oci8.c:694:in oci8lib_210.so
/usr/local/rvm/gems/ruby-2.1.10/gems/ruby-oci8-2.2.2/lib/oci8/oci8.rb:147:in `initialize'
./lib/common/oracle_connection.rb:9:in `new'
./lib/common/oracle_connection.rb:9:in `initialize'
692# Couldn't get snippet for oci8.c
Please let me know what is that I'm missing here. I have installed oracle and set oracle home path and also installed ruby oci Gem.
Check that you (the person running ruby) have correct file permissions on the Oracle directory (or directories) so you can see files. Use chmod 755 as needed.

Why my Telegram bot doesn't work in the terminal on my computer?

I am an absolute beginner in telegram bots.
I found a guide online at https://www.process.st/telegram-bot/ that should teach me how to build my first bot using ruby. I have followed the guide (installing ruby and bundler) but somehow I am note able to run the bot, nothing happens and the terminal display two errors:
Traceback (most recent call last):
2: from bot.rb:1:in `<main>'
1: from /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- telegram-bot (LoadError)
The bot directory is called telegram-bot and has 3 files inside:
Gemfile
Gemfile.lock
bot.rb
The problem occurs when I type ruby bot.rb in my terminal
The problem was the misspelling of telegram_bot, I was using the wrong spelling telegram-bot in my bot.rb file, thanks to Casper for providing me the solution

How to run wukong examples?

Wukong looks like a pretty nice Ruby way to get into Hadoop through the streaming interface. However, after looking over the examples at the git page:
https://github.com/infochimps-labs/wukong/tree/master/examples
I have no idea how to actually run any of these and generate output.
EDIT: I tried running the following example:
$ ./word_count.rb --run=local README.txt .
This generates an error:
/Users/evanzamir/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- wukong/script (LoadError)
from /Users/evanzamir/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from ./word_count.rb:2:in `<main>'
It seems to be having an issue with the line require 'wukong/script', but I'm not sure how to fix it.

Gitorious: git-poller won't start

I just installed a fresh gitorious on my server and wanted to test it when I found out that the git-poller didn't run. And it also didn't want to start.
I followed this guide: http://gitorious.org/gitorious/pages/DebianSqueezeInstallation, my system is Debian Squeeze and Ruby -v says ruby 1.8.7
Everything from that guide works so far. The system is up and running but I can't start the poller. All the poller writes into the logs is the following:
tmp/pids/poller.log
*** below you find the most recent exception thrown, this will be likely (but not certainly) the exception that made the application exit abnormally ***
#<MissingSourceFile: no such file to load -- user_auto_completions_helper>
*** below you find all exception objects found in memory, some of them may have been thrown in your application, others may just be in memory because they are standard exceptions ***
#<NoMemoryError: failed to allocate memory>
#<SystemStackError: stack level too deep>
#<fatal: exception reentered>
#<LoadError: no such file to load -- daemons>
#<TypeError: Expected a filter, an endpoint, a callable or a list of any of these.>
#<NameError: uninitialized constant ActiveMessaging>
#<MissingSourceFile: no such file to load -- user_auto_completions_helper>
tmp/pids/poller.output
/home/clients/client1/web85/web/vendor/rails/activesupport/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant ActiveMessaging (NameError)
from /home/clients/client1/web85/web/vendor/rails/activesupport/lib/active_support/dependencies.rb:80:in `const_missing'
from /home/clients/client1/web85/web/vendor/rails/activesupport/lib/active_support/dependencies.rb:92:in `const_missing'
from /home/clients/client1/web85/web/lib/gitorious/messaging/stomp_poller.rb:13
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:203:in `load'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:203:in `start_load'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/application.rb:292:in `start'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in `run'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons.rb:143:in `run'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions'
from /var/lib/gems/1.8/gems/daemons-1.1.0/lib/daemons.rb:142:in `run'
from script/poller:30
I'm using ispconfig as a webserver management tool, that's where the weird paths are from. I changed all paths from the howto to fit, tho.
Anybody got an idea? I can provide more material if needed, but I just don't know what could be usefull. This is my first question on stackoverflow so please don't shoot me if I didn't do everything right :)
After a lot of reading and trial and error (I started about 3 times from scratch, trying Ruby 1.9.2 and REE both from source and with RVM) I tried another howto[1] which had one big difference to the first one: It suggested downloading and installing Rubygems 1.4.2 instead of the apt-version of Rubygems.
At first I didn't want to do that because I was afraid that it would break my system (there are a lot of other things running on that server, including Redmine) which it did, but after I re-installed all missing gems everything worked again.
Now everything (Gitorious and Redmine) is working with apt-version of Ruby 1.8.7 and the non-apt-version of Rubygems 1.4.2.
[1] http://cjohansen.no/en/ruby/setting_up_gitorious_on_your_own_server/
Since I stumbled upon another, hopefully last problem:
I installed gitorious for my standard web user (in order to respect ISPConfig's policy) and made a new git-user for the repositories. To be able to exchange data I added both to the same usergroup and fixed the permissions.
The problem I ran into was that the git poller added new repositories for his own, that means "git:git" instead of "git:sharedgroup". To fix this you just have to set the default group id for the git-folder (/var/git in my case):
chgrp -R <group_name> /var/git
chmod -R g+s /var/git
It appears that the two commands above did work but adding a new project broke everything again because the git-poller added a folder for the project and the repository which resulted in the repository-folder having the wrong owner again.
I (hopefully) fixed that with changing my /etc/init.d/git-poller script from
/bin/su - git -c "cd /var/www/git.mydomain.com/web;RAILS_ENV=production script/poller $#"
to
/bin/su - git -c "newgrp <group_name> && cd /var/www/git.mydomain.com/web;RAILS_ENV=production script/poller $#"

Is referencing using: require '../db.rb' correct?

I need to reference my db.rb file that is lower in the directory tree.
/folder1/test.rb
/db.rb
/database.yml
running:
ruby db.rb
doesn't return an error.
In test.rb I did:
require '../db.rb'
and I get an error:
../db.rb:7:in `initialize': No such file or directory - database.yml (Errno::ENOENT)
from ../db.rb:7:in `open'
from ../db.rb:7
from test.rb:1:in `require'
from test.rb:1
Not sure what the issue is here?
The relative require itself is okay. However, require doesn't change your current working directory. So it's looking for database.yml in /folder1.
In previous Rubies, require included the calling script's directory. There were security issues with that so the '.' directory was removed in 1.9. To provide a way of getting to things in the local directory require_relative was added.
http://svn.ruby-lang.org/repos/ruby/tags/v1_9_2_0/NEWS talks about its inclusion into Core.

Resources