iOS Question Record TTS output to file

hanyelmehy

Active Member
Licensed User
Longtime User
i try to record TTS Speaking to a file
when not using record method ,TTS Volume is high
when Add Record method Volume go too low (in both cases when tts play and when recorded file play)
B4X:
Sub BT1_Click
   Rec1.Initialize(File.DirDocuments, "rec1.dat",22050, False,1, False)
    Rec1.Record
   
   
    TTS1.SetLanguage("en-US")
    TTS1.SpeechRate=StateManager.GetSetting2("TTSRate",TTS1.SpeechRate)
    TTS1.Pitch=StateManager.GetSetting2("TTSPitch",TTS1.Pitch)
    TTS1.Speak(MyText,True)

End Sub
rivate Sub TTS1_Complete(Text As String)
 
  Rec1.Stop
  Log("play")
  Mp1.Initialize(File.DirDocuments,"rec1.dat","Mp1")
  Mp1.Volume=10
  Mp1.Play
 
 
End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Call this code after you initialize the recorder and before you call record:
B4X:
#If OBJC
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
- (void)setAudioSession {
 [[AVAudioSession sharedInstance]
   setCategory:AVAudioSessionCategoryPlayAndRecord
   withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
}
#end if

Dim no As NativeObject = Me
no.RunMethod("setAudioSession", Null)

This is based on this answer: http://stackoverflow.com/questions/...e-recording-sound-with-avaudiorecorder-in-ios
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
While I can appreciate your concern, personally I don't have any problems and I prefer things as they currently stand. Maybe that is because I am using all B4x products and often code-samples are interchangeable so many queries/questions relate and I am keen on reading them all. Nonetheless I can understand and respect your point of view....
 
Upvote 0
Top