©2003 Kåre Sjölander and Jonas Beskow
Introduction Download Documentation Links Forum
WaveSurfer user forum

FAQ  FAQ
Search  Search
Memberlist  Memberlist
Register  Register
Profile  Profile
Login  Login

problems with speak.plug

 
Post new topic   Reply to topic    www.speech.kth.se/wavesurfer Forum Index -> WaveSurfer
View previous topic :: View next topic  
Author Message
Kati
Guest





PostPosted: Fri Jan 30, 2004 1:16 pm    Post subject: problems with speak.plug Reply with quote

Dear Dimitrios,

Your speak plugin sounds really exiting and I'd love to
use it!
I've installed it and changed the path to the mbrola executable and
to the database, but it won't work because of an internal error
("too few arguments for math function" )..
The file ws.pho is created, but it is empty.

I'm absolutely not an expert (student icon_smile.gif) so I think it certainly is
a mistake I made ...but I can't find it!

icon_sad.gif

Can anybody give me a hint?

Thanks,
Kati
Here is the whole error message:
Code:
too few arguments for math function
    while executing
"expr int([lindex [lindex $Info($w,pitchList) $j] 0])"
    (procedure "SpeakUp" line 46)
    invoked from within
"SpeakUp .x.s1 .x.s1.workspace.pane_3"
    (in namespace inscope "::wsurf::speak" script line 1)
    invoked from within
"::namespace inscope ::wsurf::speak {SpeakUp .x.s1 .x.s1.workspace.pane_3}"
    invoked from within
".x.s1.popup invoke active"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 [list $w invoke active]"
    (procedure "tk::MenuInvoke" line 47)
    invoked from within
"tk::MenuInvoke .x.s1.popup 1"
    (command bound to event)
Back to top
dzach



Joined: 03 Jul 2003
Posts: 41
Location: Athens, Greece

PostPosted: Fri Jan 30, 2004 8:44 pm    Post subject: Re: problems with speak.plug Reply with quote

Kati

Thank you for the error report.
The problem was caused by the early termination of pitch data.

Here is the plugin with the problem corrected.

Code:

# -----------------------------------------------------------------------------
# Speak.plug version 0.9.2, 30.1.2004
# Mbrola player plugin for wavesurfer
#
# By Dimitrios Zachariadis
# dzach@hol.gr
# http://users.hol.gr/~dzach/index.htm
#
# First release 16.1.2004
# Portions of code copied off the "meanpitch.plug"-in of the wavesurfer distribution
# -----------------------------------------------------------------------------

wsurf::RegisterPlugin speak \
    -description "Plug-in that speaks the phonemes from the current or the last label pane found, \
    using the Mbrola engine and voices. Uses the first pitch contour pane available \
    (if one exists) for prosody generation, otherwise it generates its own from the loaded sound. \
    Needs setting of the mbrola executable and voice database paths" \
    -addmenuentriesproc speak::addMenuEntries

namespace eval speak {
   variable Info
}
# ----------------------------------------------------------------------------
proc speak::addMenuEntries {w pane m hook x y} {
   if {[string match query $hook]} {
      return 0
   }    
   if {[string length $hook]==0} {
      $m add command -label "Speak" -command [namespace code [list SpeakUp $w $pane]]
   }
}
# ----------------------------------------------------------------------------
proc speak::getPitch {w} {
   variable Info

   # Use pitch values from a pitch pane if one exists, otherwise
   # compute them from scratch and remember for future reference

   foreach otherpane [$w _getPanes] {
      upvar wsurf::analysis::${otherpane}::var v
      if {$v(drawPitch)} {
         set Info($w,pitchList)     $v(pitchList)
         set Info($w,frameInterval) $v(frameInterval)
         return
      }
   }
   set s [$w cget -sound]
   set Info($w,pitchList) [$s pitch -method esps]
   set Info($w,frameInterval) 0.01
}
# ----------------------------------------------------------------------------
proc speak::SpeakUp {w pane} {
variable Info
upvar ::wsurf::trans::${pane}::var p

   if {[info exists p(nLabels)]} {
   } else {
      foreach otherpane [$w _getPanes] {
         upvar wsurf::trans::${otherpane}::var v
         if {$v(drawTranscription)} {
            upvar ::wsurf::trans::${otherpane}::var p
            set ft 1
         }
      }
   }
   if {[info exists p(nLabels)]} {
      getPitch $w
      
        if {[catch {open "ws.pho" w} out]} {
         return $out
        } else {
            if {[info command encoding] != ""} {
               fconfigure $out -encoding $p(encoding)
         } 
         fconfigure $out -translation {auto lf}
            # start is the start time of the label in the sound object
         set start 0.0
            # tp is the time pointer
         set tp 0.000
            # fi is the frame interval for the pitch contour
         set fi [expr int($Info($w,frameInterval)*1000)]
         set pitchTick 0
         set lastHz 0
            # i traverses the number of labels starting at the begining
         for { set i 0} {$i < $p(nLabels)} {incr i} {
            set sout ""
               # ind is the index of the label in the label list

            set ind [lindex $p(map) $i]
               # end is the end time of the label in msec
            set end [expr $p(t1,$ind,end)*1000]
            set label $p(t1,$ind,label)
            set dur [expr int([expr {$end - $start}]) ]
            while {$tp < $end} {
               set hz 0.0
               set per 0
               set per [expr int(100 * [expr $tp - $start] / $dur)]
                  # next statement to be replaced so that canvas pitch data is reflected to f0
               set hz [lindex [lindex $Info($w,pitchList) $pitchTick] 0]
               if {$hz != 0.0 & $hz != "" } {
                  set hz [expr int($hz)]
                  set sout "$sout $per $hz"
                  set lastHz $hz
               }
               set tp [expr $tp + $fi]
               incr pitchTick
            }
            puts $out "$label $dur $sout"
            set start $end
         }
         puts $out "_ 0 0 $lastHz"
         puts $out "#"
         close $out
#---------------------------------------------------------------------------------------
#         Change next string to the proper path of the mbrola executable and  database
# --------------------------------------------------------------------------------------
         eval exec "e:/speech/mbrola.exe e:/speech/databases/gr2 ws.pho ws.wav"
         snack::sound ss -load ws.wav
         ss play
        }
   }
}

_________________
Dimitrios
Back to top
View users profile Send private message Send email Visit posters website
Display posts from previous:   
Post new topic   Reply to topic    www.speech.kth.se/wavesurfer Forum Index -> WaveSurfer All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2.0.1 © 2001, 2002 phpBB Group