Benutzer soll Text eingeben der gesprochen werden soll

pizzaessa

Mitglied
Thread Starter
Dabei seit
03.05.2012
Beiträge
26
Reaktionspunkte
0
Hallo,

ich rätsel die ganze Zeit schon wie ich das lösen kann.

Code:
script AppDelegate
	property parent : class "NSObject"
    property eingabe : missing value
	
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened 
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
    
    on ausgeben_(sender)
        say contents of eingabe as string
    end ausgeben_
	
end script

Der Benutzer soll in ein Textfeld (Property Eingabe) etwas eingeben. Wenn dann auf den Button gedrückt wird soll der Content von Eingabe mit gesprochen werden. Irgdenwie will das nicht richtig funktionieren.

Ich freue mich auf eure Hilfe!
Pizzessa
 
So ungefähr?

Code:
[FONT="Verdana"][size=2][b]repeat[/b]
	[b]set[/b] [color=#6C04D4]result[/color] [b]to[/b] [color=#0016B0][b]display dialog[/b][/color] "Geben Sie den Text ein: " [color=#0016B0]default answer[/color] "" [color=#0016B0]buttons[/color] {"Abbrechen", "Ok"} [color=#0016B0]default button[/color] 2
	[b]if[/b] [color=#4315B1]button returned[/color] [b]of[/b] [color=#6C04D4]result[/color] [b]is[/b] "Ok" [b]then[/b]
		[color=#0016B0][b]say[/b][/color] [color=#4315B1]text returned[/color] [b]of[/b] [color=#6C04D4]result[/color]
	[b]else[/b]
		[b]return[/b]
	[b]end[/b] [b]if[/b]
[b]end[/b] [b]repeat[/b][/size][/FONT]
 
Das kann ich auch :)
Aber ich will das in Cocoa-Objective C machen (mit den Propertys und so)
 
Warum dann nicht gleich die NSSpeechSynthesizer class?
 
So ähnlich könnte es in etwas aussehen (ungetestet):

Code:
#import <Cocoa/Cocoa.h>

@interface SpeechExample : NSObject {

    NSSpeechSynthesizer *mySpeechSynthesizer;
    IBOutlet NSTextField *inputTextField;

}

-(IBAction)speak:(id)sender;

@end

Code:
#import "SpeechExample.h"

@implementation SpeechExample

-(void)awakeFromNib
{
    mySpeechSynthesizer = [[NSSpeechSynthesizer alloc] initWithVoice:nil];
}

- (IBAction)speak:(id)sender
{
    NSString *aText = [inputTextField stringValue];
    [mySpeechSynthesizer startSpeakingString:aText];
}

@end
 
Zurück
Oben Unten