Autor Beitrag
Mephisto090
Hält's aus hier
Beiträge: 9

WinXP
Turbo Delphi
BeitragVerfasst: Sa 02.01.10 21:50 
hi,

Kurz und Knapp:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
// Aufbau Des THreads
type
  TSpeak = class(TThread)
  private
    FText: String;
    FVoice: OLEVariant;
  protected
    procedure Execute; override;
  public
    constructor Create(Text: String);
  end;


// Das Diese Computerstimme was Vorliest
procedure TSpeak.Execute;
begin
  FVoice:= CreateOLEObject('SAPI.SpVoice');
  FVoice.Speak(FText, 0);
end;


// Create vom Thread
constructor TSpeak.Create(Text: String);
begin
  inherited Create(false);
  FText:= Text;
  FreeOnTerminate:=True;
end;

// Thread Createn
procedure TForm1.btn1Click(Sender: TObject);
begin
  th:= TSpeak.Create('Hello');
end;


Diese beiden fehler bekomme ich:

Erste Gelegenheit für Exception bei $7C812AFB. Exception-Klasse EOleSysError mit Meldung 'CoInitialize wurde nicht aufgerufen'. Prozess Project1.exe (2224)

Erste Gelegenheit für Exception bei $7C812AFB. Exception-Klasse EOleSysError mit Meldung 'CoInitialize wurde nicht aufgerufen, ProgID: "SAPI.SpVoice"'. Prozess Project1.exe (2224)

Bitte um Hilfe danke
Mfg Mephi
Flamefire
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1207
Erhaltene Danke: 31

Win 10
Delphi 2009 Pro, C++ (Visual Studio)
BeitragVerfasst: Sa 02.01.10 21:59 
1 Minute bei google:
hier
Mephisto090 Threadstarter
Hält's aus hier
Beiträge: 9

WinXP
Turbo Delphi
BeitragVerfasst: Sa 02.01.10 22:10 
so soweit klappt das ja schon das ich die Form auf wenn er sprich bewegen kann bloß ich habe das jetzt ine ine klasse gemacht und er sagt nix mehr

danke schonmal soweit

Edit mir ist aufgefallen das ich die Var: 'oleVoice: OLEVariant;' nicht Local setzen darf sondern Privat
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: So 03.01.10 14:33 
Moin!

In jedem Thread-Context ist ein eigenes CoInitialize erforderlich, deshalb könnte das so klappen: :idea:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
// Das Diese Computerstimme was Vorliest
procedure TSpeak.Execute;
begin
  CoInitialize(NIL);
  FVoice:= CreateOLEObject('SAPI.SpVoice');
  FVoice.Speak(FText, 0); // unterstellt, dass diese Methode blockiert
  CoUnInitialize;
end;
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.