Guys, I need your help with the last piece of my
voice-by-computer program. the appended section compiles to
the binary xD that lets the user choose the gender,
word-per-minute speed, delay-between-words, and pitch of th
e voice. Without this 'option' the user would type hello
and hit enter, a male voice would sound thru the speakers.
that's okay for *me*, nut probably not so if the user is a women
with impaired speech. in short, this callback option lets the
user select the gender and fine tune it.
I will let future developers deal with the text editor.
right now, vim is fine.
can anyone on this gtk list help me get this squared away?
thanks in advance,
gary kline
--
Gary Kline kl...@thought.org http://www.thought.org Public Service Unix
Voice By Computer (for Universal Access): http:/www.thought.org/vbc
The 8.57a release of Jottings: http://jottings.thought.org
Twenty-six years of service to the Unix community.
/*
Compile::
gcc -Wall -Wextra -g dD.c -o xD `pkg-config --cflags gtk+-2.0` `pkg-config
--libs gtk+-2.0`
*/
/* from here make this into:: Options callback */
#include gtk/gtk.h
#include string.h
#include stdlib.h // for exit()
#define PITCH 17.0
#define SPEED 100.0
#define VOLUME 100.0
#define DELAY 3.0
enum
{
MALE,
FEMALE
};
#define CONFIG /tmp/chatConfig
/* globals */
GtkWidget *gender_radio_male;
GtkWidget *gender_radio_female;
GtkWidget *pitch_scale1;
GtkWidget *speedWPM_scale2;
GtkWidget *volume_scale3;
GtkWidget *delay_scale4;
int valueGender = MALE; // default
double valuePitch, valueSpeed, valueVolume, valueDelay;
/* end globals */
/*
main prog writes default; this fn read and asks if ok
*/
void data_inout();
FILE *ifp, *ofp; /* in and out FILE pointers for fopen */
#define FALSE(0)
#define TRUE(~0)
static void
cb_gender_toggled (GtkToggleButton *button, gpointer userdata)
{
int malefemale = (int)userdata;
if (gtk_toggle_button_get_active (button))
{
if (malefemale == MALE)
{
fprintf(stdout, Male \n);
}
else if (malefemale == FEMALE)
{
fprintf(stdout, Female \n);
}
}
valueGender = malefemale;
fprintf(stderr,valueGender: %d\n,valueGender);
}
static void hscale_value_changed_pitch (GtkRange *hscale, GtkWindow
*parentWindow)
{
valuePitch = gtk_range_get_value(hscale);
//fprintf(stderr,hscale pitch value: %g\n,valuePitch);
if (valueGender == 0)
{
fprintf(stdout, \ngender is Male\n);
}
else
{
fprintf(stdout, \ngender is Female\n);
}
fprintf(stdout,In _pitch_: patch = %g, speed = %g, volume = %g delay = %g\n,
valuePitch, valueSpeed, valueVolume, valueDelay);
}
static void hscale_value_changed_speed (GtkRange *hscale, GtkWindow
*parentWindow)
{
valueSpeed = gtk_range_get_value(hscale);
fprintf(stderr,hscale speed value: %g\n,valueSpeed);
}
static void hscale_value_changed_volume (GtkRange *hscale, GtkWindow
*parentWindow)
{
valueVolume = gtk_range_get_value(hscale);
fprintf(stderr,hscale volume value: %g\n,valueVolume);
}
static void hscale_value_changed_delay (GtkRange *hscale, GtkWindow
*parentWindow)
{
valueDelay = gtk_range_get_value(hscale);
fprintf(stderr,hscale delay value: %g\n,valueDelay);
}
int
main (int argc, char *argv[])
{
/*
* Declare the GTK Widgets used in the program
*/
GtkWidget *dialog;
GtkWidget *main_hbox; //hbox1
GtkWidget *gender_frame;
GtkWidget *gender_align;
GtkWidget *gender_hbox; // hbox2
GtkWidget *params_frame;
GtkWidget *params_align;
GtkWidget *params_table;
GtkWidget *temp_widget;
GtkWidget *parent_window;
/*
Initialize GTK
*/
gtk_init (argc, argv);
parent_window = NULL; //Set to parent window if you want the dialog box
//to block access to the other windows in the app
//while it is open and running.
dialog = gtk_dialog_new_with_buttons (Voice Settings, GTK_WINDOW
(parent_window),
0,
GTK_STOCK_REVERT_TO_SAVED, //revert button which
GTK_RESPONSE_CANCEL,// returns a cancel response
GTK_STOCK_CLOSE,//close button which
GTK_RESPONSE_ACCEPT,// returns an accept response
NULL// mark the end of our buttons (we could have
more)
);
gtk_window_set_title ( GTK_WINDOW ( dialog ) , VBC Espeak Options);
gtk_widget_set_usize( GTK_WIDGET ( dialog ) , 600 , 400 );
//GTK_WINDOW ( dialog ) -allow_shrink = TRUE;
/*
* dialog boxes have a vbox built in we can use
*/
main_hbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
/*
* Create the first frame
*/
gender_frame = gtk_frame_new (bVoice Gender/b);
gtk_frame_set_shadow_type (GTK_FRAME (gender_frame), GTK_SHADOW_NONE);