![]() |
|
Sesli yazma - Baskı Önizleme +- Delphi Can (https://www.delphican.com) +-- Forum: Delphi (https://www.delphican.com/forumdisplay.php?fid=3) +--- Forum: Mobil Platform - FireMonkey (FMX) (https://www.delphican.com/forumdisplay.php?fid=7) +--- Konu Başlığı: Sesli yazma (/showthread.php?tid=2246) |
Sesli yazma - gonulali - 18-05-2018 Selamlar, Android uygulamamda Edit 'in yanına bir mikrofon işareti koyup yazmak istediğimi sesli olarak söyleyip otomatik yazdırabilir miyim acaba? Whatsappdaki gibi. Cvp: Sesli yazma - elixir84 - 18-05-2018 @gonulali Merhaba zamanında bende uğraşmıştım. Sana örnek proje gönderiyorum. Kendine göre ayarlarsın. Proje İndir Cvp: Sesli yazma - DelphiCan - 18-05-2018 (18-05-2018, Saat: 10:35)elixir84 Adlı Kullanıcıdan Alıntı: @gonulali Merhaba zamanında bende uğraşmıştım. Sana örnek proje gönderiyorum. Kendine göre ayarlarsın. Paylaşım için teşekkürler. Her üyemizin kodu indirip inceleme şansı veya zamanı olmuyor maalesef. Doğrudan proje paylaşımı ile beraber; projenin mümkünse ekran görüntüsü, içerdiği koda ilişkin birkaç ipucu veya kullanmış olduğunuz kod ve kısa bir bilgi paylaşabilirseniz, konuyu okuyan üyelerimiz projeniz konusunda bilgilenecektir. Cvp: Sesli yazma - elixir84 - 18-05-2018 @DelphiCan ![]() unit Unit1;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Effects,
FMX.Ani, FMX.StdCtrls, FMX.Layouts, FMX.ListBox, FMX.Objects,
FMX.Controls.Presentation,android.speech
{$IFDEF ANDROID}
,Androidapi.JNI.Net
,Androidapi.JNI.GraphicsContentViewText
,Androidapi.JNI.JavaTypes
,Androidapi.JNI.App
,FMX.Platform.Android
,FMX.Helpers.Android
,Androidapi.Helpers
,Androidapi.JNIBridge
,Androidapi.JNI.Os, FMX.Edit
{$ENDIF};
type
TForm1 = class(TForm)
voicepanel: TRectangle;
Label1: TLabel;
Layout1: TLayout;
Label2: TLabel;
ListBox1: TListBox;
Layout2: TLayout;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
FloatAnimation1: TFloatAnimation;
ShadowEffect1: TShadowEffect;
Image2: TImage;
karanlik: TRectangle;
Edit1: TEdit;
Button1: TButton;
Image7: TImage;
procedure Button1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure FloatAnimation1Finish(Sender: TObject);
private
procedure ShowPopup;
procedure HidePopup;
procedure sesliarama;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.fmx}
function ErrorMessage(Error: Integer): string;
begin
case Error of
TJSpeechRecognizer_ERROR_AUDIO: Result := 'Ses kayıt hatası';
TJSpeechRecognizer_ERROR_CLIENT: Result := 'Diğer istemci tarafı hatalar';
TJSpeechRecognizer_ERROR_INSUFFICIENT_PERMISSIONS: Result := 'Yetersiz izinler';
TJSpeechRecognizer_ERROR_NETWORK: Result := 'Diğer Ağ ile ilgili hatalar';
TJSpeechRecognizer_ERROR_NETWORK_TIMEOUT: Result := 'Ağ işlemi zaman aşımına uğradı';
TJSpeechRecognizer_ERROR_NO_MATCH: Result := 'Hiçbir tanıma sonucu eşleşti';
TJSpeechRecognizer_ERROR_RECOGNIZER_BUSY: Result := 'Tanıma Hizmet meşgul';
TJSpeechRecognizer_ERROR_SERVER: Result := 'Sunucu hatası durumu';
TJSpeechRecognizer_ERROR_SPEECH_TIMEOUT: Result := 'Herhangi bir konuşma girişi Bulunamadı';
else Result := 'Tanımlanamaya Hata ' + IntToStr(Error);
end;
end;
type
TRecognitionListener = class(TJavaLocal, JRecognitionListener)
procedure onBeginningOfSpeech; cdecl;
procedure onBufferReceived(Buffer: TJavaArray<Byte>); cdecl;
procedure onEndOfSpeech; cdecl;
procedure onError(Error: Integer); cdecl;
procedure onEvent(EventType: Integer; Params: JBundle); cdecl;
procedure onPartialResults(PartialResults: JBundle); cdecl;
procedure onReadyForSpeech(Params: JBundle); cdecl;
procedure onResults(Results: JBundle); cdecl;
procedure onRmsChanged(RmsdB: Single); cdecl;
end;
procedure TRecognitionListener.onBeginningOfSpeech;
begin
Form1.label2.text := 'Konuşma Başladı';
end;
procedure TRecognitionListener.onBufferReceived(Buffer: TJavaArray<Byte>);
begin
end;
procedure TRecognitionListener.onEndOfSpeech;
begin
Form1.label2.text := 'Konuşma Bitti';
end;
procedure TRecognitionListener.onError(Error: Integer);
begin
Form1.label2.text:='Hata: ' + ErrorMessage(Error);
end;
procedure TRecognitionListener.onEvent(EventType: Integer; Params: JBundle);
begin
end;
procedure TRecognitionListener.onPartialResults(PartialResults: JBundle);
begin
end;
procedure TRecognitionListener.onReadyForSpeech(Params: JBundle);
begin
Form1.label2.text:='Konuçma İçin Hazır';
end;
procedure TRecognitionListener.onResults(Results: JBundle);
var
ArrayList: JArrayList;
I: Integer;
Text: string;
begin
Text := '';
ArrayList := Results.getStringArrayList(StringToJString(TJSpeechRecognizer_RESULTS_RECOGNITION));
Form1.Listbox1.Clear;
for I := 0 to ArrayList.size - 1 do
Form1.Listbox1.Items.Add(JStringToString(ArrayList.get(I).toString));
Form1.label2.text:='Sonuçlar';
Form1.Edit1.SetFocus;
end;
procedure TRecognitionListener.onRmsChanged(RmsdB: Single);
begin
end;
var
SpeechRecognizer: JSpeechRecognizer;
RecognitionListener: JRecognitionListener;
procedure Tform1.sesliarama;
begin
Edit1.Text:='';
label2.text:='';
Listbox1.Clear;
if not TJSpeechRecognizer.JavaClass.isRecognitionAvailable(SharedActivityContext) then
begin
ShowMessage('Konuşma tanıma mevcut değil');
Exit;
end;
CallInUiThread(
procedure
begin
if SpeechRecognizer = nil then
begin
SpeechRecognizer := TJSpeechRecognizer.JavaClass.createSpeechRecognizer(SharedActivityContext);
RecognitionListener := TRecognitionListener.Create;
SpeechRecognizer.setRecognitionListener(RecognitionListener);
end;
SpeechRecognizer.startListening(TJRecognizerIntent.JavaClass.getVoiceDetailsIntent(SharedActivityContext));
end);
ShowPopup;
end;
procedure TForm1.ShowPopup;
begin
FloatAnimation1.StartValue:= -voicepanel.Height;
FloatAnimation1.StopValue:= (self.Height / 1.5)-(voicepanel.Height-2);
voicepanel.Visible:=true;
karanlik.Visible:=true;
FloatAnimation1.Start;
end;
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
Edit1.Text:=Listbox1.Selected.Text;
//if Edit1.text<>'' then cariarama; //arama yaptırılabilir
Edit1.SetFocus;
hidePopup;
end;
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
HidePopup;
end;
procedure TForm1.FloatAnimation1Finish(Sender: TObject);
begin
if FloatAnimation1.StartValue <> 0-voicepanel.Height then
begin
voicepanel.Visible:=false;
karanlik.Visible:=false;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
HidePopup;
end;
procedure TForm1.HidePopup;
begin
FloatAnimation1.StartValue:= (self.Height / 2)-(voicepanel.Height-2);
FloatAnimation1.StopValue:= 0-voicepanel.Height;
FloatAnimation1.Start;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
sesliarama;
end;
end.
Sesli yazma - narkotik - 18-05-2018 Bu gerçekten banada lazımdı eline sağlık Sesli yazma - gonulali - 18-05-2018 @elixir84 Çok teşekkürler. Telefonumda çalıştırdığımda sesli aramaya bastığımda kendini kapatıyor program. Bazende konuşmaya başladığımda kapatıyor. neden olabilir? Eksik birşey olabilir mi acaba? Cvp: Sesli yazma - elixir84 - 19-05-2018 (18-05-2018, Saat: 19:10)gonulali Adlı Kullanıcıdan Alıntı: @elixir84 Çok teşekkürler. Telefonumda çalıştırdığımda sesli aramaya bastığımda kendini kapatıyor program. Bazende konuşmaya başladığımda kapatıyor. neden olabilir? Eksik birşey olabilir mi acaba? @gonulali Delphi 10.2.3 de derlendi onunla alakası olabilir mi? Cvp: Sesli yazma - gonulali - 19-05-2018 Bende firemonkey 10.1 kurulu.onda derliyorum konuşma hazır diyor konuşuyorum, konuşma bitti yazıp programı kapatıyor telefonda. Dediğiniz versiyondamı yapmam gerek acaba? Cvp: Sesli yazma - elixir84 - 19-05-2018 @gonulali Burdaki projeyi indirip denermisin. https://github.com/FMXExpress/Firemonkey/tree/master/Winsoft/SpeechRecognizerForAndroid Sesli yazma - gonulali - 19-05-2018 Evet buradaki sorunsuz çalıştı. Çok teşekkürler @elixir84 |