Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speech to text, or almost voice chat

#1
I describe how to chat while playing, by speaking (not typing), without the necessity of the recipients installing additional software. As it is a kludge, you may want to change the details.

First install some speech to text software, such as nerd-dictation. Remember to download models for one or more languages.

As far I know, for security Xonotic can not execute external programs. So we'll have a script for executing nerd-dictation when some specific files in the .xonotic directory get changed.

Consider the following script (depending on inotify tools), which you may need to adapt, as it presupposes some directory names and that the models you have are named model-en and model-pt.

Code:
#!/bin/bash

set -eu

xondir="$HOME"/.xonotic/data/

diagn() {
  printf "%s\n" "$1" >> /dev/stderr
}

main() {
  cd "$xondir"

  outfile="$xondir"/voiceout
  nerddic="$HOME"/gits/nerd-dictation/nerd-dictation

  while true ; do
    diagn "Waiting signal..."
    # Change the languages here:
    file=$(inotifywait --format %w -e modify en pt)
    diagn "Received start signal: $file"
    echo -n > "$file"
    {
      model="$HOME"/gits/nerd-dictation/model-$file/
      res=$("$nerddic" begin --numbers-as-digits --vosk-model="$model" --output STDOUT | tr '\n' ' ')
      diagn "Writing text...: $res"
      printf "set nerddic_text \"%s\"" "$res" > "$outfile"
    } &
    diagn "Waiting stop signal..."
    inotifywait -e modify voicestop
    diagn "Received stop signal"
    echo -n > voicestop
    "$nerddic" "end";
  done
}

main

Inside the .xonotic/data/ directory create the empty files: voiceout, voicestop, en and pt.

Add the following (or similar) to .xonotic/data/autoexec.cfg:

Code:
set nerddic_text "<unitialized>"

set lang en

alias voiceask "condump $lang"

alias voicestop "condump voicestop"

alias voicerecstart "cprint Recording voice... ($lang); voiceask"

alias voiceexecres "exec voiceout"

alias voicerecend "voicestop; cprint Processing, wait how much I do not know"

alias voicesayres_ "say ${nerddic_text}"

alias voicesayres "voiceexecres; voicesayres_"

alias voiceshowres_ "cprint ${nerddic_text}"

alias voiceshowres "voiceexecres; voiceshowres_"

alias voiceteamsayres_ "say_team ${nerddic_text}"

alias voiceteamsayres "voiceexecres; voiceteamsayres_"

Then start the bash script, and run Xonotic.

Note that some files are modified with condump, which writes the entire console history, a bit inefficient. Anyway, speech to text demands more power and time.

You may change the language with the Xonotic console command lang pt. You may bind some of these commands to some key presses; the command voiceshowres shows the interpreted text before publishing.

You may want to change the code to automatically send the text after recording; caution with race conditions.

It seems to be slightly practical (not much in phrenetic games). I couldn't test it rigorously because I'm not a fluent anglophone, nor I have a quality microphone.

Thanks for the attention. Suggestions? Also, I'm grateful for this marvelous game.
Reply



Possibly Related Threads...
Thread Author Replies Views Last Post
  Chat color question Molnija 0 1,760 11-14-2018, 02:26 AM
Last Post: Molnija
  Remove color font from scoreboard and drag notify, but not chat Molnija 6 3,969 09-14-2018, 10:28 PM
Last Post: Molnija
  I want to implement voice chat lamefun 3 4,205 12-22-2013, 08:00 PM
Last Post: unfa
Rainbow Colorful in-game chat Melanosuchus 13 13,067 09-05-2013, 12:49 PM
Last Post: Mr. Bougo
Question Text right to left (xonotic menu) kariminf 5 5,842 07-08-2013, 06:00 AM
Last Post: Mr. Bougo
Brick Weapons defined in text files / de-harding weapons [feature debate] MirceaKitsune 41 36,089 10-10-2012, 03:59 PM
Last Post: hutty
  Game key bindings working while typing text AviyaL 3 4,512 09-23-2012, 05:35 AM
Last Post: Mr. Bougo
  Chat / taunt HUD portraits (need help from other coders!) MirceaKitsune 12 14,409 03-26-2011, 11:04 PM
Last Post: Lee_Stricklin

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-