06 August 2020

Text To Speech (TTS) and Audio file with NativeScript

In my game - My first game (game for children), that created with NativeScript, I use audio and speak services.

The NativeScript is platform that use to develop an android (or IOS) app with angular and TypeScript.

Here is the class the use for Audio and Speak with NativeScript.

The speak if Text To Speech (TTS) from google.

The audio is mp3 file

import { TNSTextToSpeechSpeakOptions } from "nativescript-texttospeech";
import { TNSPlayerAudioPlayerOptions } from "nativescript-audio-player";
import * as timer from "tns-core-modules/timer";
import { Injectable } from "@angular/core";
import * as firebase from "nativescript-plugin-firebase";
  providedIn: "root",
export class AudioAndSpeak {
  public audioTrackDurationany;
  public remainingDurationany// used to show the remaining time of the audio track
  private TTS = new TNSTextToSpeech();
  private _playerTNSPlayer;
  public isSpeakingboolean = false;
  constructor() {
    this._player = new TNSPlayer();
    this._player.debug = false;
  public async speak(textstringlocal : string) {
    let isSpeaking = true;
    let  speakRate = 0.8;
    let speakOptionsSpeakOptions = {
      text: text,
      speakRate: speakRate,
      queue: true,
      locale : local,
      finishedCallback: async () => {
        isSpeaking = false;
    this.TTS.speak(speakOptions).then(() => console.log("End Speak"));
    return isSpeaking;
  public async playSound(filePathstringfilePath2?: stringvolume? :number) {
    try {
        volume = 1;
      this._player.volume = volume;
      this.isSpeaking = true;
      const playerOptionsAudioPlayerOptions = {
        audioFile: filePath,
        loop: false,        
        completeCallback: async () => {
          await this._player.dispose();
          this.isSpeaking = false;          
         // player disposed
          if (filePath2) {
        errorCallback: (errorObject=> {
          this.isSpeaking = false;
        infoCallback: (args=> {
      await this._player.playFromFile(playerOptions).catch((error=> {
        firebase.crashlytics.sendCrashLog('AudioAndSpeak -> playSound playFromFile :' + error);
        this.isSpeaking = false;
      this.audioTrackDuration = await this._player.getAudioTrackDuration();
      // start audio duration tracking
    } catch (e) {
      console.error("AudioAndSpeak -> playSound"e);
      firebase.crashlytics.sendCrashLog('AudioAndSpeak -> playSound :' + e);
  private async _startDurationTracking(durationvolume) {
    if (this._player && this._player.isAudioPlaying()) {
      this._player.volume = volume;
      const timerId = timer.setInterval(() => {
        this.remainingDuration = duration - this._player.currentTime;
      }, 500);

You need yo add the service on the contractor

import { AudioAndSpeak } from "../../shared/AudioAndSpeak";

    private audioAndSpeakAudioAndSpeak,
  ) {...}

to call audio file


to call speak

this.audioAndSpeak.speak'TEXT' , "en-GB" );

Roi Kolbinger

28 June 2020

Game built in Angular and Typescript- for Android users with NativeScript

During the corona virus vacation, I took the time to learn something new- NetiveScript.
I took a course - at one of the best in the market - Maximilian Schwarzmüller.


I built a game for my girls.

For Hebrew speakers
Ages 2-4 they will learn Colors, Shapes and Animals.
Ages  4-6 who will teach Numbers and Letters
Ages  6-9 who will teach addition and multiplication .. and learning English in stages ... Letters Numbers, Colors, Shapes and Animals.
For English speakers, the same thing only in English.

Now because everything is object-based .. I tried another language - Spanish .. In the meantime, there are only Numbers and Animals.

The game itself is written in angular and typescript.
It has 3 main components.
Component for choosing a language, Component for chose a game and of course Component of the game itself..

NativeScript gives me, as a web developer, the ability to build an app for both Android and iOS

The game is now in Google play - and Called - My First Game


Over time, I'll post my insights from NativeScript

Install ... Let the kids play and I'd love to get feedbacks ...

26 June 2020

SharePoint Service Provisioning - the service stuck on starting

When I tried to run SharePoint service - Manage Metadata Web Service on the Central Admin ... I wait and still Staring (Stuck)...

So again I ran the command (From SharePoint PowerShell)

Get-SPServiceInstance -Server SERVERNAME| where-object  {$_.TypeName -eq "Managed Metadata Web Service"} | Start-SPServiceInstance -confirm:$false > $null

And I got the Error

Start-SPServiceInstance : An object of the type Microsoft.SharePoint.Administration.SPServiceInstanceJobDefinition named "job-service-instance-ba7339e3-fb42-49c4-ac66-ab08e84eae0f" already exists under the parent Microsoft.SharePoint.Administration.SPTimerService named "SPTimerV4".  Rename your object or delete the existing object. At line:1 char:111 + ... eb Service"} | Start-SPServiceInstance -confirm:$false > $null +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     + CategoryInfo          : InvalidData: (Microsoft.Share...ServiceInstance:    SPCmdletStartServiceInstance) [Start-SPServiceInstance], SPDuplicateObject   Exception     + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletStartSer    viceInstance

I deleted the job

$jobToDelete = Get-SPTimerJob | ? { $_.name -eq "job-service-instance-ba7339e3-fb42-49c4-ac66-ab08e84eae0f" }

You tried to stop again

Stop-SPServiceInstance -Identity ba7339e3-fb42-49c4-ac66-ab08e84eae0f

But I also got the job stuck - Deleting it again 

$jobToDelete = Get-SPTimerJob | ? { $_.name -eq "job-service-instance-ba7339e3-fb42-49c4-ac66-ab08e84eae0f" }

I stopped timerJob on the server 

Then I tried a different way

$service = Get-SPServiceInstance -Identity ba7339e3-fb42-49c4-ac66-ab08e84eae0f

iisreset /noforce

I was waiting to see that he was really disabled

iisreset /noforce

I turned on the TimerJob

And It works :)

21 March 2019

Restore Problem "Restore-SPSite : The extension

Next article - User's responsibility only!

Years ago, I saw something in one of the blogs ... but I did not find any mention of it today (maybe Microsoft asked to delete the article because ...).

I tried to migrate a DataBase between two environments, but I was told the versions did not match. Probably updates winsows

Then I'll try through the power shell


But I got the following error

Restore Problem "Restore-SPSite: The extension Microsoft.Office.Project.Server.Database.Extension.ProjectDatabaseExtension is version VVVV, and the backup was on version VVV These versions are incompatible.

So what did I do?

Do a backup before ... may be you will need it

I opened the file in binary editor. In Visual Studio -> open file

Open With

Open as binary file editor

And find the wrong virsion

Now replace the number to your current virsion

And try to run the command again (Restore-SPSite)

For me it work ... hope for you too ... if you did not return the backup

27 February 2017

Converting SharePoint site from Version 2013 to 2016

In this time Microsoft did a good job with Migration SharePoint 2013 to SharePoint 2016, and within a few hours it is possible to upgrade the site from 2013 to 2016
Even the code in Visual Studio was easy to upgrade  fron VS 2013 to VS 2015 update 3 with Office package

I did this steps
  1.  Save wsp website (version 2013)
  2. Copy (backup restore) the DataBase from SQL 2012 DB 2016, and to ensure that it has sp admin privileges DB_Owner to the new DB
  3. In Central Adminstration -> Manage web applications

    a. Creating a Web Application with DB temporary
    b. Create a Site Collection
    c. Setting up the site in the hosts found in the C:\Windows\System32\drivers\etc\ with a local IP
  4.  Add the wsp site (Old from 2013)
    a. In powerShell -> Add-SPSolution -LiteralPath PATH
    b. Installing the solotion site (or in powerShell -> Install-SPSolution or in Central Adminstration -> System Settings -> Manage farm solutions)
  5. Remove the temporary DB site (in Central Adminstration -> Application Management -> Databases -> Manage content databases DB click on the question and select the Remove content database and click OK)
  6. Temporarily connect the DB from 2013 (Test-Mount-SPContentDatabase "DB_FROM_2013" -WebApplication "NEW_WEB_APP" in powershell)
  7. If it is good then, connect the DB from 2013 (Mount-SPContentDatabase "DB_FROM_2013" -WebApplication "NEW_WEB_APP" in powershell)
  8. Run Upgrade-SPSite -VersionUpgrade in powerShell
  9. In your own time, Do a Conversion of the wsp from 2013 to 2016 (Big code works great, this is becuse Microsoft didn't change the mapping of layouts folder - it still 15)
  10. Good Luck :)