first commit

This commit is contained in:
Jeena Paradies 2010-09-24 22:42:52 +02:00
commit 925bd4a7a2
14 changed files with 7146 additions and 0 deletions

59
SpeakerAppDelegate.m Normal file
View file

@ -0,0 +1,59 @@
//
// SpeakerAppDelegate.m
// Speaker
//
// Created by Jeena on 24.09.10.
// Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "SpeakerAppDelegate.h"
@implementation SpeakerAppDelegate
@synthesize window, textView;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
synth = [[NSSpeechSynthesizer alloc] init];
oldRange = NSMakeRange(-1, -1);
}
-(IBAction)speakAction:(id)sender {
if ([synth isSpeaking]) {
[synth pauseSpeakingAtBoundary:NSSpeechWordBoundary];
} else {
NSRange range = [textView selectedRange];
if (range.location == [[[textView textStorage] string] length]) {
range.location = 0;
[textView setSelectedRange:NSMakeRange(0,0)];
[textView scrollRangeToVisible:NSMakeRange(0,0)];
}
if (range.length != oldRange.length || range.location != oldRange.location) {
NSString *wholeText = [[textView textStorage] string];
NSString *text = nil;
if (range.length > 0) { // selection
text = [wholeText substringWithRange:range];
} else { // only pointer
text = [wholeText substringWithRange:NSMakeRange(range.location, [wholeText length] - range.location)];
}
[synth startSpeakingString:text];
oldRange = range;
} else {
[synth continueSpeaking];
}
}
}
@end