#import "Speech.h"

@implementation Speech


// NAME: init
// PURPOSE: To initialize this object and the Synthesizer
// IMPORTS: nil
// EXPORTS: nil
// REMARKS: 

- (id)init
{
    self = [super init];
    if (self)
	{
        synth = [[NSSpeechSynthesizer alloc] init]; //Allow the default voice to run
        [synth setDelegate:self];
        [synth startSpeakingString: @"Welcome to the Braille Converter."];
		NSLog(@"Speech active");
    }
	
    return self;
}


// NAME: speak
// PURPOSE: To speak the given text
// IMPORTS: textToSpeak
// EXPORTS: nil
// REMARKS: 

- (void)speak:(NSString*)textToSpeak
{

    if( [synth isSpeaking] )
	{
	    [synth stopSpeaking];
	}
    [synth startSpeakingString:textToSpeak];
    NSLog(@"Spoke: %@",textToSpeak);
}

- (void)delloc
{
    [synth release];
}


@end
